0
我使用我的控制器將圖像加載到視圖中。它的工作原理,但我有以下錯誤,當我加載視圖:在渲染視圖之前加載數據
%7B%7Bimage.thumbnail%7D%7D:1 GET http://localhost:9000/%7B%7Bimage.thumbnail%7D%7D 404 (Not Found)
儘管如此,有錯誤,它的工作原理,但我試圖擺脫它。
下面是我在做什麼之前:
控制器:
app.controller("WeddingGalerieCtrl", function($scope, $http) {
$http.get(url)
.then(function(response){
$scope.images=response.data;
console.log($scope.images);
});
})
觀點:
<ul class="list" >
<li lightgallery class="list-item" ng-repeat="image in images">
<a href="{{image.big}}">
<img class="img-responsive" src="{{image.thumbnail}}" alt="" />
</a>
</li>
</ul>
我嘗試添加一個解析功能,使視圖呈現在我的數據將加載,但我仍然有同樣的錯誤。
.when('/gallery/wedding', {
templateUrl: 'views/gallery.html',
controller: 'WeddingGalerieCtrl',
css: ['../styles/galleries.css','../styles/lightgallery.css'],
resolve: {
images: function($http) {
return $http.get(url).then(function(response) {
return response.data;
});
}
}
})
app.controller("WeddingGalerieCtrl", function($scope, $http, images) {
$scope.images = images;
})