to uplo...">

Image does not load using AngularJS ng-repeat and ng-src directive

So basically, when I used my own html5, I used five tags <img src="">to upload five images. When I wanted to use AngularJS, I thought about running divfive times through ng-repeatand using ng-src=""get an image whose original path is stored in an array in the controller. But some of them, as always, get this errorGET file:///home/sanad/Desktop/drag/x.source net::ERR_FILE_NOT_FOUND

This is my html:

<div ng-repeat="x in img">{{x.source}}
    <img ng-id="x.id" ng-src="x.source" >
</div>

This is my js:

var app=angular.module('d2d',[]);
app.controller('imageCtrl',function($scope){
    $scope.img=[
        {id:'table',source:'images/table.jpg'},
        {id:'paper',source:'images/paper.jpg'},
        {id:'computer',source:'images/computer.jpg'},
        {id:'ac',source:'images/ac.jpg'},
        {id:'sofa',source:'images/sofa.jpg'}
    ];
});
+4
source share
3 answers
 <div  ng-repeat="x in img">
     <img ng-src="{{x.source}}" >
 </div>`

I'm not sure what ng-src does, so I did not offer it in the first place.

, -, html, . , , ,...

Edit:

src="{{param}}" ng-src="{{param}}" url http:\\yourServer\{{param}}, . ng-src .

+6

<img ng-repeat="x in img" src="{{x}}">

+2
<img ng-repeat="x in img" ng-src="{{x.source}}">

If you only have an array of images

<img ng-repeat="img in images track by $index" ng-src="{{img}}">
0
source

Source: https://habr.com/ru/post/1569284/


All Articles