Angular function call inside html

I saw if there is a way to call the function that I created inside the scope.

<ul class="ui-listview ui-radiobutton" ng-repeat="meter in meters"> <li class = "ui-divider"> {{meter.DESCRIPTION}} {{htmlgeneration}} </li> </ul> $scope.htmlgeneration = function() { blah blah } 

The function is called html generation. Essentially, I want to dynamically add html inside an LI element when using angular.

+13
javascript angularjs
source share
2 answers

Yes, just add a parenthesis (function call). Make sure the function is in scope and is actually returning something.

 <ul class="ui-listview ui-radiobutton" ng-repeat="meter in meters"> <li class = "ui-divider"> {{ meter.DESCRIPTION }} {{ htmlgeneration() }} </li> </ul> 
+31
source share

When calling a function from HTmL, as @SomeKittens said, your function will be called more than once. What for? The answer is here . So be careful when calling a function from HTML. This may slow down the loading of your page.

0
source share

All Articles