Thứ Ba, 10 tháng 3, 2015

AngularJS: ng-directives

AngularJS


---o0o---


Original link

1. AngularJS

  • is a JavaScript framework. It is a library written in JavaScript.
  • is distributed as a JavaScript file
  • starts automatically when the web page has loaded
  • AngularJS can be added to a web page with a script tag

    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>

  • AngularJS extends HTML with ng-directives.

2. ng-directives

  • ng-app: defines an AngularJS application.
  • ng-model: binds the value of HTML controls (input, select, textarea) to application data.
  • ng-bind: binds application data to the HTML view.

Note: You can use data-ng-, instead of ng-, if you want to make your page HTML5 valid.

 
<div ng-app="">
<p>Name: <input type="text" ng-model="name"></p>
Your Name: <span ng-bind="name"></span>
 
 
  • ng-app: Tells AngularJS that the <div> element is the "owner" of an AngularJS application.
  • ng-model: binds the value of the input field to the application variable name.
  • ng-bind: binds the innerHTML of the <p> element to the application variable name.
Please fill input below

Name:

Your Name:

Không có nhận xét nào:

Đăng nhận xét