AngularJs不显示列表项中的图像

时间:2016-12-14 07:06:44

标签: javascript html angularjs

我有一个以angular:

定义的简单列表
defaultPointer.list=[
            {name:'Scott',age:29,img:'http://localhost/learn/angular/img/1.jpg'},
            {name:'Steve',age:19,img:'http://localhost/learn/angular/img/2.jpg'},
            {name:'Ben',age:39,img:'http://localhost/learn/angular/img/3.jpg'},
            {name:'Penny',age:12,img:'http://localhost/learn/angular/img/4.jpg'}
            ];

以下是HTML:

<li ng-repeat="x in defaultPointer.list | filter:defaultPointer.search">
                <img ng-src="{{ x.img }}"/> <span>{{x.name | uppercase}} is {{ x.age }}</span>
            </li>

出于某种原因,它在控制台中显示空白且没有错误。可能是什么问题?

enter image description here

1 个答案:

答案 0 :(得分:0)

请使用我的代码并进行检查:

defaultPointer.list=[
            {name:'Scott',age:29,img:'img/1.jpg'},
            {name:'Steve',age:19,img:'img/2.jpg'},
            {name:'Ben',age:39,img:'img/3.jpg'},
            {name:'Penny',age:12,img:'img/4.jpg'}
            ];

以下是HTML:

<li ng-repeat="x in defaultPointer.list | filter:defaultPointer.search">
                <img ng-src="{{ x.img }}"/> <span>{{x.name | uppercase}} is {{ x.age }}</span>
            </li>

您必须将此html文件放在角文件夹中。