AngularJs(一)

摘要:AngulaJs(一)

<!DOCTYPE html>
<html ng-app="">
<head >
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head >
<body>
  <input type="text" ng-model="a">
  <br/>
  {{a}}
</body>
</html>

在html標籤內宣告 ng-app 或 ng-app="" 開始AngulaJs

在兩組花括號 "{{}}"內 可以做些運算 顯示 等...............

{{123}}  顯示數字123
{{"Hello World"}} 顯示字串Hello World
{{9+1}} 顯示運算結果10
{{"Hello"+"World""}} 顯示字串運算結果HelloWorld
{{modelName}} 顯示model結果

呼叫angularjs指令可以使用 ":"     " -"     "_"   來連接   或開頭     "x"     'data" 

<!doctype html>
<html ng-app>
  <head>
    <script src="http://code.angularjs.org/1.0.6/angular.min.js"></script>
    <script src="script.js"></script>
  </head>
  <body>
    <div ng-controller="Ctrl1">
      Hello <input ng-model='name'> <hr/>
      <span ng:bind="name"> <span ng:bind="name"></span> <br/>
      <span ng_bind="name"> <span ng_bind="name"></span> <br/>
      <span ng-bind="name"> <span ng-bind="name"></span> <br/>
      <span data-ng-bind="name"> <span data-ng-bind="name"></span> <br/>
      <span x-ng-bind="name"> <span x-ng-bind="name"></span> <br/>
    </div>
  </body>
</html>