Reputation: 1413
Let's take for example this(user edit) page:
http://img38.imageshack.us/img38/6032/4gg6.png
and the controller for this page:
function userEditCtrl($scope) {
$scope.user = {
personalData: {
firstName: '...',
lastName: '...'
},
contacts: [{}, {}, {}],
someOtherData: {
field: 'value'
}
};
}
in the page we have 3 sections (personal data, contacts and some other data), in the user object we also have corresponding fields.
what is the best practice for creating separate controller for every section (userPersonalDataEditCtrl, userContactsEditCtrl, userSomeOtherDataEditCtrl)?
Thank You!
Upvotes: 0
Views: 57
Reputation: 702
Best approach is create 3 different controller and directive for each this controller, because you have 3 independent sections. Each controller must work only with its own directive.
Upvotes: 1