It is recommended to use a consistent prefix across all controllers. The recommended way to name controllers ares:
Having a consistent controller provides the following advantages:
It is also recommended to append the suffix Controller
to every controller's name. The Controller
suffix is more commonly used and is explicitly descriptive.
Note: This issue works based on the developer's eslint config. Changing the preferred controller naming format can be done by changing the rule's option for the rule named angular/controller-name
.
// error: The MyCtrl controller should follow this pattern: /^[A-Z][a-zA-Z0-9]*Controller$/
angular
.module('myModule')
.controller('MyCtrl', function () {
// ...
});
angular
.module('myModule')
.controller('MyController', function () {
// ...
});