Thursday, February 18, 2016

Initializing multiple variables in ‘ng-init’ for AngularJS application

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="" data-ng-init="var1=5;var2=7; varStr='Hello'">
<p> <span data-ng-bind="varStr"></span></p>
<p> var1 = <span data-ng-bind="var1"></span></p>
<p>var2 = <span data-ng-bind="var2"></span></p>
<div>var1+var2 = {{(4+5)}}</div>

</div>

</body>
</html>

No comments:

Post a Comment