Error |
Column 1: "Based on the Component-First Pattern, you should avoid the use of controllers"
angular/no-controller
|
Error |
Column 1: "There may be at most 1 AngularJS component per file, but found 2"
angular/component-limit
|
1 |
angular.module('myApp') |
2 |
.controller('GreetUserController', function GreetUserController($scope) { |
3 |
var users = [{name:'world'}, {name:'earth'}, {name:'planet'}, {name:'mars'}]; |
4 |
|
5 |
findFirstUser(); |
6 |
|
7 |
function findFirstUser() { |
Error |
Column 13: "You should not set properties on $scope in controllers. Use controllerAs syntax and add data to "this""
angular/controller-as
|
Error |
Column 35: "Prefer '_.map' over the native function."
lodash/prefer-lodash-method
|
8 |
$scope.user = _.first(users.map(function(user) { |
9 |
return user.name; |
10 |
})); |
11 |
} |
12 |
}) |
13 |
.directive('greetUser', function(){ |
Error |
Column 9: "Directive should be implemented with the component method."
angular/prefer-component
|
14 |
return { |
15 |
restrict: 'E', |
16 |
replace: true, |
17 |
template: 'Hello, {{user}}!', |
18 |
controller: 'GreetUserController' |
19 |
}; |
20 |
}); |