Answer the question
In order to leave comments, you need to log in
AngularJS, IonicFramework why does the controller work only the first time?
The controller itself:
.controller('FavsCtrl', function($scope, $http, Clubs) {
$scope.favs = Clubs.getFavs();
if ($scope.favs.length) {
$http.get('http://localhost:6789/club/' + $scope.favs.join(",")).success(function(data, status, headers, config) {
$scope.favs = data;
}).error(function(data, status, headers, config) {
alert('Error '+status+', data is: '+data);
}).finally(function(data) {
});
} else {
alert('Нет избранного');
}
}
})
.state('tab.favs', {
url: '/favs',
views: {
'tab-favs': {
templateUrl: 'templates/tab-favs.html',
controller: 'FavsCtrl'
}
}
})
.factory('Clubs', function() {
return {
getFavs: function() {
var favs = localStorage.getItem("favs");
return (favs ? JSON.parse(favs) : []);
}
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question