日期:2014-05-16  浏览次数:20350 次

angularJs(一)指令

1、调用

指令调用可以ng:bindng-bindng_bindx-ng-bind , data-ng-bind这些方式

<!doctype html>
<html ng-app>
  <head>
    <script src="http://code.angularjs.org/angular-1.1.0.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>

script

function Ctrl1($scope) {
  $scope.name = 'angular';
}

2、指令的编写(短板)

html

<!doctype html>
<html ng-app="time">
  <head>
    <script src="http://code.angularjs.org/angular-1.1.0.min.js"></script>