在 html 中拆分对象的第一个元素

Split first element of object in html

在我的汽车对象中我有一个值 car.photos 它看起来像这样:

car.photos :

15214615_01_hd.jpg|15214615_02_hd.jpg|15214615_03_hd.jpg|15214615_04_hd.jpg|15214615_05_hd.jpg|15214615_06_hd.jpg|

我的问题是:在我的 html 中是否可以使用 ng-src 显示我的 car.photos 的第一个元素?

我的html:

<tr ng-repeat="car in $data">
                <td><img class="img-rounded resize" ng-src="../photos/15214615_01_hd.jpg"></td>
...
</tr>

你可以称它为getSrc()

<img class="img-rounded resize" ng-src="{{ getSrc(car.photos) }}">

在控制器中,

$scope.getSrc = function (photos) {
    return  photos.split("|")[0];
}