angular

1、样式相关指令

ng-class 用来给元素绑定类名

1)类名字符串,可以用空格分割多个类名

2)类名数组,数组中的每一项都会层叠起来生效

3)键值为类名,值为boolean类型,当值为true时,该类会被加在元素上。

ng-style用来帮顶元素的css样式

ng-show,ng-hide 对元素显示隐藏的控制

2、表单控件相关指令

ng-checked控制radio和checkbox的选中状态

ng-selected控制下拉框的选中状态

ng-disabled控制失效状态

ng-multiple控制多选

ng-readonly控制只读状态

3、事件绑定相关指令

ng-click

ng-change

ng-mousedown

ng-mouseenter

ng-mouseleave

ng-mousemove

ng-mouseover

ng-mouseup

ng-submit

二、service

1、factory

app.controller('myApp',function($scope,myFactory){
  $scope.artist=myFactory.getArtist();  
}
app.factory('myFactory',function(){
    var _artist='';
    var service={};
    service.getArtist=function(){
        return _artist;
    }
     return service;
});

2、service

app.controller('myApp',function($scope,myService){
   $scope.artist=myService.getArtist();
}
app.service('myApp',function(){
   var _artist='hello';
   this.getArtist=function(){
        return _artist;
   }
});
原文地址:https://www.cnblogs.com/beng/p/3833080.html