AngularJS 指令是擴展的 HTML 屬性,帶有前綴 ng-。html
ng-app 指令初始化一個 AngularJS 應用程序。app
ng-init 指令初始化應用程序數據。spa
ng-model 指令把元素值(好比輸入域的值)綁定到應用程序。code
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script> </head> <body> <div ng-app="" ng-init="firstName='John'"> <p>在輸入框中嘗試輸入:</p> <p>姓名: <input type="text" ng-model="firstName"></p> <p>你輸入的爲: {{ firstName }}</p> </div> </body> </html>