angular js

1.控制器  <div ng-app="" ng-controller="personController">

 function personController($scope) {
    $scope.person = {
        firstName: "John",
        lastName: "Doe",

      fullName: function(){

     var x = $scope.person;

   return x.firstName + " "+ x.lastName;
   }

    };
}

控制器也可带有方法,用{{fullName}}调用下面的方法:

$scope.fullName = function() {
var x = $scope.person;
return x.firstName + " " + x.lastName;
}

 

ng-repeat 指令会重复一个 HTML 元素:

<ul>
  <li ng-repeat="x in names">
    {{ x.name + ', ' + x.country }}
  </li>
</ul>

2.过滤器可以使用一个管道字符(|)添加到表达式和指令中。

 <p>name:{{person.lastName | uppercase}}</p>  //将lastName中所有的小写变成大写 ,lowercase将所有的大写变成小写

<li ng-repeat="x in names | orderBy:'country'">

<li ng-repeat="x in names | filter:name | orderBy:'country'">
{{ (x.name | uppercase) + ', ' + x.country }}
</li>

 

3.AngularJS $http 是一个用于读取web服务器上数据的服务。

$http.get(url) 是用于读取服务器数据的函数。

4.Angularjs html 事件

ng-click 指令定义了一个 AngularJS 单击事件。

 

 

posted @ 2014-09-14 21:10  长清  阅读(371)  评论(0编辑  收藏  举报