angular.js-component和directive

angular.js组件化:为了达到ui的复用,将页面分成几部分。可以通过组件化来实现。

angular.module('myApp',[])

.component('myComponent',{

controller:myComonentController,

controllerAs:'myComCtrl',

link:link,

bindings:{

data :'

},

templateUrl:'my-component.html',

require:{}

})

directive指令

通过指令来为html拓展新功能,内置指令添加新功能,允许你自定义指令。

1.ng-*,内部指令。

2.使用.directive来创建自定义指令。

angular.module('myApp',[])

.diective('myDirective',function(){

return  {

restrict:'',

controller:,

controllerAs:'',

template:'',

replace:,

scope:{


}

}

})

3.调用指令:

元素

属性

类名

和注释<--- directive: my-directive  ------>。

你可能感兴趣的:(angular.js-component和directive)