Answer the question
In order to leave comments, you need to log in
How to form the correct Angularjs 1.x data model?
This question has been discussed many times already, I looked, but I did not find a clear answer anywhere.
How to properly structure the model for working with data? namely, the essence of the problem, so that with each change in data, the appearance of a new event, etc., the data is updated and the user sees all the changes after saving, deleting, adding.
It would be really not bad to tell point by point how an adequate model should look like, how an adequate model should work.
Or throw good articles, books, where this topic is chewed.
One of the useful articles:
At the moment, all requests from the server are executed in the service:
angular.module('app.user.projects')
.service('ApiProjects', ['$http', 'API',
function ($http, API) {
var ApiProjects = {
getInfo: function (id) {
return $http.get(API.url + 'project/info?project_id='+ id)
},
getAimsList: function (id) {
return $http.get(API.url + 'project/aims?project_id='+ id)
},
getAimInfo: function (id) {
return $http.get(API.url + 'project/aims/'+ id)
},
return ApiProjects;
}]);
resolve: {
projectId: ['$stateParams', function($stateParams){
return $stateParams.id;
}],
projectInfo: ['ApiProjects', 'projectId', function(ApiProjects, projectId){
return ApiProjects.getInfo(projectId);
}],
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