controller-as rule matches custom scope functions
Hi, I believe controller-as rule should not fail on following code:
$scope.on('myEvent', handleEvent);
I'm not setting properties on $scope, I'm calling its function.
I see my mistake already (it's $on) and that it's correctly working for $on, but I believe that if there is some custom method on $scope - no matter where it is set - I should be allowed to call it in controller. Hence, issue is still valid.
I think a custom method $scope.myCustomMethod must be initialized on some parent scope and than your independent controller depends on code from a higher scope. Therefore I'm not sure if this example is valid. I mean, it is valid scenario but looks still like a use case with better possible solutions. Please correct me if I've overseen something.
Sorry, I missed it in my emails. I agree with you, however it deserves separate rule or separate config option. "controller-as" says "You should not set properties on $scope in controllers". Maybe let's make a rule "controller-as-use" or similar to say "You should not use properties or methods on $scope in controllers" ?
+1, in my case I'm using angular-bootstrap's modal service which adds to the $scope two following methods: $dismiss() and $close(). There's no other way to use it. Also $scope.$watch() happens to be useful.
Still, as mentioned above, the warning shouldn't say "You should not set properties on $scope [...]" as it's misleading. Two separate rules would be better, don't you think?