Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Contributor: Ravishankar ChavarePart 6.3-ng-init Directives
#1
ng-init Directives

-For defining initial value for an application.
-sometime when you need some local data for your web application you can get it done by ng-init directive

Syntax:
Code:
<element ng-init="expression"></element>


Example:
Code:
<div ng-init="text='hello'">
{{text}}
</div>



FULL EXAMPLE:
Code:
<!DOCTYPE html>
<html ng-app="">
<head >
    <script src="../angular.min.js"></script>
    <title>ng-init</title>
</head>
<body>
<div ng-init="name='protutr'"></div>//initialize name local variable here

Here text will be printed which we defined in ng-init derictives<br>
{{name}}

</body>
</html>


OUTPUT:

[Image: e791vsf.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)