distributed
distributed copied to clipboard
$scope is used too much in mainController
Currently mainController.js is a big file with lot of business logic and functionality defined in $scope.
From what I learned so far it's better to use controllerAs syntax and reduce the use of $scope. Also business logic should reside in controller.
I think this is a good time to refactor mainController.js to make the codebase better
Do you mean something like this?
`<div ng-controller="MainCtrl as main">
{{ main.title }}
</div>`
And also, I would suggest using 'this' instead of binding everything to scope all the time.
app.controller('MainCtrl', function () { this.title = 'Some title'; });
What do you guys think? @Roshanjossey , @glauberramos
@alanjsph, Yes. Did you get it from here ?
I was thinking about extracting directives and controllers out to different files.
Just keeping view in directives and put business logic in controllers.
@Roshanjossey , No I didnt get it from there. But aren't the directives already in different files? Correct me if I'm wrong.
Yes directives are in multiple files. It'd be good to split controllers too.
I don't really know how it should end up. There are functions to be used by different directives.
ok, @Roshanjossey Let me have a try