angular.js-component和directive

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

<my-component data='1'></my-component>

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.调用指令:

元素<my-directive></my-directive>,

属性<div my-directive></div>,

类名<div class='my-directive'></div>

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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容