Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 1.2 KB

no-controller.md

File metadata and controls

41 lines (27 loc) · 1.2 KB

no-controller - disallow use of controllers (according to the component first pattern)

According to the Component-First pattern, we should avoid the use of AngularJS controller.

Rule based on Angular 1.x

Examples

The following patterns are considered problems;

/*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

The following patterns are not considered problems;

/*eslint angular/no-controller: 2*/

// valid
angular.module('myModule').directive('helloWorld', function () {
    return {
        template: '<div>{{ text }}',
        controller: function ($scope) {
            $scope.text = 'Hello World';
        }
    };
});

Version

This rule was introduced in eslint-plugin-angular 0.9.0

Links