更新:它適用於Firefox,但不適用於Chrome!有任何想法嗎???Angularjs:圖片不會加載
我正在學習一個簡單的智能手機/平板電腦列表的縮略圖。 http://docs.angularjs.org/tutorial/step_07
問題:我確實在執行步驟7,縮略圖不會再加載。
它實際上是在前面的步驟,但我無法弄清楚我做錯了什麼。如果我直接在網址欄中調用圖片網址,它就會起作用。但是Angular不知道怎麼做。我在Chrome的JavaScript控制檯中也沒有遇到任何錯誤。
縮略圖都位於/應用/ IMG /手機/(例如/app/img/phones/dell-streak-7.0.jpg)
下面是我認爲是相關的文件。如果你需要更多的英特爾,讓我知道。非常感謝!
/app/index.html
<!doctype html>
<html lang="en" ng-app="phonecatApp">
<head>
<meta charset="utf-8">
<title>My HTML File</title>
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/bootstrap.css">
<!-- Angular imports -->
<script src="lib/angular/angular.js"></script>
<script src="lib/angular/angular-route.js"></script>
<!-- My imports -->
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
</head>
<body>
<div ng-view></div>
</body>
</html>
/app/partials/phone-list.html
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<!--Sidebar content-->
Search: <input ng-model="query">
Sort by:
<select ng-model="orderProp">
<option value="name">Alphabetical</option>
<option value="age">Newest</option>
</select>
</div>
<div class="span10">
<!--Body content-->
<ul class="phones">
<li ng-repeat="phone in phones | filter:query | orderBy:orderProp" class="thumbnail">
<a href="#/phones/{{phone.id}}" class="thumb"><img ng-src="{{phone.imageUrl}}"></a>
<a href="#/phones/{{phone.id}}">{{phone.name}}</a>
<p>{{phone.snippet}}</p>
</li>
</ul>
</div>
</div>
</div>
/app/js/app.js
'use strict';
/* App Module */
var phonecatApp = angular.module('phonecatApp', [
'ngRoute',
'phonecatControllers'
]);
phonecatApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/phones', {
templateUrl: 'partials/phone-list.html',
controller: 'PhoneListCtrl'
}).
when('/phones/:phoneId', {
templateUrl: 'partials/phone-detail.html',
controller: 'PhoneDetailCtrl'
}).
otherwise({
redirectTo: '/phones'
});
}
]);
個/app/js/controllers.js
'use strict';
/* Controllers */
var phonecatControllers = angular.module('phonecatControllers', []);
phonecatControllers.controller('PhoneListCtrl', ['$scope', '$http',
function ($scope, $http) {
$http.get('phones/phones.json').success(function(data) {
$scope.phones = data;
})
$scope.orderProp = 'age'
}
]);
phonecatControllers.controller('PhoneDetailCtrl', ['$scope', '$routeParams',
function($scope, $routeParams) {
$scope.phoneId = $routeParams.phoneId
}
]);
如果他們解決了你的Batarang門票,我很想知道問題所在。它看起來像一個有用的工具 – BenCr