Привет Я работаю над приложением angularjs. Это фактически встроено в joomla.
URL-адрес, который удовлетворяет json-ответам, изменяется в зависимости от выбранного пункта меню. Например:
http://localhost/testsite/index.php/good?format=raw
http://localhost/testsite/index.php/bad?format=raw
http://localhost/testsite/index.php/ugly?format=raw
Есть ли способ, которым я могу использовать location.path вместо hardcoding URL.
Мой контроллер ниже:
var app = angular.module('myApp', ['ui.bootstrap']);
app.filter('startFrom', function() {
return function(input, start) {
if(input) {
start = +start; //parse to int
return input.slice(start);
}
return [];
}
});
app.controller('customersCrtl', function ($scope, $http, $timeout) {
$http.get('http://localhost/testsite/index.php/good?format=raw').success(function(data){
$scope.list = data[0]; //before the code was $scope.list = data; The second response with [[that doesn't work is an array with an array inside of it.
$scope.currentPage = 1; //current page
$scope.entryLimit = 10; //max no of items to display in a page
$scope.filteredItems = $scope.list.length; //Initially for no filter
$scope.totalItems = $scope.list.length;
});
$scope.setPage = function(pageNo) {
$scope.currentPage = pageNo;
};
$scope.filter = function() {
$timeout(function() {
$scope.filteredItems = $scope.filtered.length;
}, 10);
};
$scope.sort_by = function(predicate) {
$scope.predicate = predicate;
$scope.reverse = !$scope.reverse;
};
});
надеюсь, что вы можете помочь.