How to tell PhpStorm/WebStorm that $ctrl
in a template is known and also help it decide the controller it belongs to (maybe using jsdoc)?
I create components in this manner in Angular 1.5:
angular
.module('myModule')
.component('myComponent', {
templateUrl: "my.component.html",
controller : [
MyComponentController
]
});
ControllerAs
didn't help...
HTML snippet of where the problem appears ($ctrl.*
):
<div class="entity-summary clear" ng-click="$ctrl.toggleInfo()">
<div class="entity-col">
{{$ctrl.entity.id}}
</div>
<div class="entity-col">
{{$ctrl.entity.host}}
</div>
</div>
Unfortunately Angular 1.5 components are not yet fully supported, please follow WEB-20339 for updates
You can avoid most of the noise by (mis)using ng-init="$ctrl=$ctrl":
<div ng-init="$ctrl=$ctrl"
ng-click="$ctrl.toggleInfo()"
class="entity-summary clear" >
<div class="entity-col">
{{$ctrl.entity.id}}
</div>
<div class="entity-col">
{{$ctrl.entity.host}}
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With