Answer the question
In order to leave comments, you need to log in
How to organize everything in AngularJs?
Suppose there is a certain UserCntrl controller, which, for example, registers a user at a minimum or logs him in, and something else. And there is a factor, as I understand it, it is she who acts as a model here, well, in the sense of not a database model, but the one that accesses the api (maybe I’m talking nonsense, I’m only studying angular for a couple of days) UserFctr
So is it worth organizing like this: i.e. create one large controller for the model (factory) User and in it some kind of enumeration to do on the method and already call it there in the factor
angular
.module('starter', [])
.controller('UserCntrl', ['$scope', 'User', function($scope, User) {
for (var key in $scope) {
switch (key)
case 'register':
вызываем User(с данными)
[break]
case 'Login':
вызываем User(с данными)
[break]
...
case labelN:
statementsN
[break]
}
}
}]) или лучше сделать много разных контроллеров для User(фактори)
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