Liquid Liquid - 3 months ago 9
AngularJS Question

angular filter in a mouse event variable

Is there a way place a filter in a variable that is being changed on mouse events?

For example if I have

ng-mouseover="text = 'Create a new item in this list'"
and I would like to replace it with a filter that reads a translation from a JSON file:
ng-mouseover="text = '{{'create_new'|translate}}'"


But this is not acceptable in angular. Is it syntactically wrong or it's simply not possible?

Answer

you can do it like that:

ng-mouseover ="item.showText = true"

ng-moseleave = "item.showText=false"

than you can set html-css class on the your item and set its ng-show attribute like:

ng-show="item.showText"

example:

 <label class=".." ng-Model="item" ng-mouseover ="item.showText = true" ng-moseleave = "item.showText=false"> {{item.text}} </label>

<span ng-show="item.showText">{{'create_new' | translate }}</span>

This is not exactly solution, this is only idea for you. As I said you can solve this with css-html support.