Answer the question
In order to leave comments, you need to log in
Where to store data when working with angular.js?
I'm starting to learn angular.js and can't figure out where to store the data.
I have an array like:
.controller('myCtrl', function ($scope) {
$scope.links = [{
url: 'http://',
ancor: 'some string',
}];
}
<nav>
<a ng-repeat="link in links" ng-href="{{link.url}}">{{link.ancor}}</a>
</nav>
Answer the question
In order to leave comments, you need to log in
In the service
stackoverflow.com/questions/18036629/inject-a-conf...
Everything that is not a directive, not a controller goes to the service
You can, of course, put it in a separate file, for example. But you, probably, will pull everything from the server, right?
.controller('myCtrl', function ($scope) {
$scope.links = linksList;
}
var linksList = [{
url: 'http://',
ancor: 'some string',
},
{
url: 'http://2',
ancor: 'some string2',
}
];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question