I'm working on a directive template that features a basic toggle variable.
<div ng-mouseenter="$ctrl.myToggle = true" ng-mouseleave="$ctrl.myToggle = false">
...
</div>
<div ng-if="$ctrl.myToggle">
... toggled content
</div>
Currently, I am using TypeScript to write my controllers.
Should I include myToggle
in my controller class even though it won't be actively used? (I don't require a toggle function since this attribute is the only thing that needs to change)
export MyController {
public myToggle:boolean = false;
construtctor(){
//...
}
//...
}
Do you think it’s not advisable to have such logic solely in the template?