Thursday, June 19, 2014

Hello AngularJS

This article explains how to get started with AnglularJS and develop a simple application

Step 1: Include angular js file
Step 2: Include ng-app attribute (bootstrap our application.)
Step 3: Include ng-model attribute that need to be mapped to view.

Source:

<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

Enter your name : <input type="text" ng-model="ename">
<br>

Hello {{ ename }}

<script type="text/javascript" src="../js/lib/angular.min.js"></script>
</body>

</html>


Whenever you type anything on the text box, the value gets bound to the model and in the code, we display whatever is present in the mode.

Note:
-          {{ ename }} is angularJS expressions where ename is model attribute. Ename is bound to the text box as well, so whenever the text box is changed, the model attribute value is changed and vice versa.
-          ng-model is an attribute used to bind the model with the view.

-          All the special html tags and attributes are called as “directives” in angularJS.

No comments:

Post a Comment