Use of controllers is discouragedJS-0525
angularjs
According to the Component-First pattern, we should avoid the use of AngularJS controller.
Rule based on Angular 1.x
Bad Practice
/*eslint angular/no-controller: 2*/
// invalid
angular.module('myModule').controller('HelloWorldController', function ($scope) {
$scope.text = 'Hello World';
}); // error: Based on the Component-First Pattern, you should avoid the use of controllers
Recommended
/*eslint angular/no-controller: 2*/
// valid
angular.module('myModule').directive('helloWorld', function () {
return {
template: '<div>{{ text }}',
controller: function ($scope) {
$scope.text = 'Hello World';
}
};
});