0
我試圖在列表中顯示圖像。圖像的路徑存儲在名爲imagesUrls
的數組中。如何從AngularJS模板訪問數組
imagesUrls['dhd.png'] = "./img/brands/dhd.png" imagesUrls['channelislands.png'] = "./img/brands/channelislands.png"
等等
<ion-item collection-repeat="item in prodataSelect | unique:'brand' | orderBy:'brand'" collection-item-height="75" >
<img class="selectBrandImage" ng-src="imagesUrls['{{item.brand | nospace | lowercase}}.png']" />
<span classs="selectBrandName">{{item.brand}}</span>
</ion-item>
controllers.js:
prodata = sessionService.get('prodata');
$scope.prodataSelect = prodata;
$scope.imagesUrls = sessionService.get('imagesUrls');
我找不到模板的ng-src
正確的語法,你能幫助請?
我也試過這樣:
ng-src="getImgPath(item.brand)"
與此:
$scope.getImgPath = function(str) {
return imagesUrls[$filter('nospace')($filter('lowercase')(str))];
}
當您檢查瀏覽器中的元素時,src的值是多少?你有我們可以玩的小提琴嗎? – ltalhouarne
當我檢查的值是src =「imagesUrls ['carroll.png']」 – Louis
你試過src而不是ng-src嗎? – ltalhouarne