javascript - How to call function in an HTML attribute that only accepts string values / literals? -
i having issues calling function within attribute in jade file:
test.jade
script - function myfunction(str) { regex on str, say, filter out full stops , return new string. } .container-fluid .row .col-md-12 div(ng-repeat='thing in things') button(popovertext='{{thing.description()}}', popover-trigger='mouseenter')
the expression in popovertext attribute prints strings fine each thing in things (as done ng-repeat) without calling function. far i'm told, popovertext accepts string values, when did like
button(popovertext='myfunction({{thing.description()}})')
it prints out myfunction(....the original string....), means doesn't recognise function @ all. i'm supposed call function in jade file , not externally in .js file, because apparently attribute doesn't have 'ng-' doesn't communicate controllers @ all?
how can possibly around this?
also, confused regarding when should put "-" in front of line of code. right in saying that, jade, need var, function, , return?
a possible way around setting field called descriptionstring thing object. can in controller:
angular.foreach(things, function(thing){ thing.descriptionstring = thing.description(); });
the rest easy:
button(popovertext='{{thing.descriptionstring}}', popover-trigger='mouseenter')
Comments
Post a Comment