Я получаю данные от BooksController, и он загружает все параметры. Но он не отображает список. Возможно, это что-то на HTML, но я не уверен, что именно.
Код: Выделить всё
var app = angular.module('MyApp', [])
.controller('BooksController', function($scope, LocationService) {
$scope.categories = [
{
"Id": "-1",
"Name": "All Books"
}, {
"Id": "0",
"Name": "Computer Science"
},{
"Id": "1",
"Name": "Physics"
},{
"Id": "2",
"Name": "History"
},{
"Id": "3",
"Name": "Geography"
}, {
"Id": "4",
"Name": "Fiction"
}];
$scope.categoryId = null;
$scope.BooksList = null;
LocationService.GetBooks().then(function(d) {
$scope.BooksList = d.data;
});
$scope.GetBookByCategory = function() {
$scope.BooksList = null;
LocationService.GetBooksFiltered($scope.categoryId).then(function(d) {
$scope.BooksList = d.data;
}, function(error) {
alert('Error!');
});
}
})
.factory('LocationService', function ($http) {
var fac = {};
fac.GetBooksFiltered = function(categoryId){
return $http.get('/Home/Get?predicate=' + categoryId)
}
fac.GetBooks = function(){
return $http.get('/Home/GetAll')
}
return fac;
});Код: Выделить всё
Filter By: {{item.Name}}
[list]
[*][url=#]{{item.Name}}[/url]
[/list]
Подробнее здесь: https://stackoverflow.com/questions/376 ... -angularjs