javascript - Angular 无法在检查器中加载资源错误

标签 javascript angularjs angularjs-ng-repeat

我正在使用 Angular 的 ng-repeat 上传虚拟内容。

var app = angular.module("homeApp", []);
app.controller("entriesView", function ($scope){
$scope.itemEntry = [            
{
    image: "img/112013-priscilla-600.jpg",
    title: "ymc",
    logo: "http://www.youmustcreate.com/site/wp-content/themes/youmustcreate/images/core/header-logo.jpg"
},

{
    image: "https://cms.myspacecdn.com/cms/x/13/47/112013-priscilla-600.jpg"
}    
  ];

 });

HTML

<section class="miniframe-wrapper" ng-controller="entriesView">
    <section ng-repeat="itemEntry in itemEntry" class="miniframe">
    <img src="{{itemEntry.image}}" alt="img"/>

我注意到在检查器中我收到无法加载资源错误,但是图像出现在我的浏览器上。有谁知道到底是什么导致了这个问题。我正确引用了我的图像吗?

最佳答案

使用字符串插值时,在图像标签中使用 ng-src 而不是 src。 ng-src 解析字符串,然后将 src 分配给标签,而 vanilla html 正在寻找名为“{{dataEntry.image}}”的图像

关于javascript - Angular 无法在检查器中加载资源错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20168366/

相关文章:

javascript - 将数组拆分为多个字符串 Javascript

javascript - AngularJS 和 MongoDB (CRUD) 保存/更新——不工作

angularjs - 使用angularjs在ng-repeat中显示数组的数量

performance - Angularjs - 优化 ngrepeat 的观察者以仅观察集合的某些属性

javascript - 代码不工作::$ ("#pmhxform input:checkbox:checked").each(function() { var id= $(this).id(); });

angularjs - 如何让 Angular 在 Angular 错误上显示错误?

python - AngularJS+Flask 无法实例化模块

javascript - 如何双重嵌套 Angular ng-repeat

javascript - 使用 ng-repeat 创建 DOM 属性

javascript - 如何检索 $locationProvider?