AngularJS Expressions

AngularJS Expressions को {{ }} इस मात्रा का इस्तेमाल करके लिखा जा सकता है|

AngularJS expressions को हम directive के अंदर भी लिख सकते है । इसमें हम literals, operators, and variables डाल सकते है।
AngularJS expressions ko hum HTML ke andar likh sakte hai

Example {{ 2 + 2 }}

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

<div ng-app=””>
<p>My first expression: {{ 2 + 2 }}</p>
</div>

</body>
</html>


Agar aap upar diye gaye udaaharan me se ng-app directive nikal denge to HTML ise bina solve kiye hue dikhayega, jaise likha hai waise hi. Ab isme ng-app directive hone ke kaaran ye hame “2 + 2” ka result 4 solve karke dikhayega.

Angularjs Expressions me aap numbers, strings, objects, arrays de sakte hai. Niche aur ek udaaharan diya hai hamne expressions ka objects ka istamal karte hue:

<div ng-app=”” ng-init=”person={firstName:’Ravi’,lastName:’Sharma’}”>

<p>The name is {{ person.lastName }}</p>

</div>

Aaiye ek array ka bhi example dekh lete hai:

<div ng-app=”” ng-init=”counts=[10,20,30,40,50]”>

<p>Second count is = {{ counts[2] }}</p>

</div>

Iska result hoga 20

Dhyan rahe ki AngularJS expressions conditionals, loops, and exceptions ko support nahi karte

2 Comments

Add a Comment

Your email address will not be published. Required fields are marked *