I have this plunker.How to make that function to be executed only one time ?
The code is:
<!DOCTYPE html>
<html>
<head>
<script data-require="angular.js@1.1.5" data-semver="1.1.5" src="http://code.angularjs.org/1.1.5/angular.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-app>
<div ng-controller="testCtrl">
<h3>Why does scope function executes X times</h3>
<div>getLabel executed {{counter}} times</div>
<div>getLabel result {{getLabel('test')}}</div>
<div ng-bind="myModel.tmp"></div>
<div ng-bind="myModel.tmp2"></div>
</div>
</body>
</html>
Output:
Why does scope function executes X times
getLabel executed 10 times
getLabel result My label
Temp value
Temp value 2
I have executed the code here:
http://plnkr.co/edit/LLQ7cKs2fEoBwv0C5XPE?p=preview
2 Answer(s)