Skip to content

Latest commit

 

History

History
52 lines (34 loc) · 1.46 KB

controller-as-route.md

File metadata and controls

52 lines (34 loc) · 1.46 KB

controller-as-route - require the use of controllerAs in routes or states

You should use Angular's controllerAs syntax when defining routes or states.

Rule based on Angular 1.x

Styleguide Reference

Examples

The following patterns are considered problems;

/*eslint angular/controller-as-route: 2*/

// invalid
$routeProvider.when('/myroute', {
    controller: 'MyController'
}) // error: Route "/myroute" should use controllerAs syntax

// invalid
$routeProvider.when('/myroute', {
    controller: 'MyController as vm',
    controllerAs: 'vm'
}) // error: The controllerAs syntax is defined twice for the route "/myroute"

The following patterns are not considered problems;

/*eslint angular/controller-as-route: 2*/

// valid
$routeProvider.when('/myroute', {
    controller: 'MyController',
    controllerAs: 'vm'
});

// valid
$routeProvider.when('/myroute', {
    controller: 'MyController as vm'
});

Version

This rule was introduced in eslint-plugin-angular 0.1.0

Links