指令
指令-进行DOM操作
指令四种基本形式
HTML形式
<div hello></div>
<div class="hello"></div>
<!-- directive:hello -->
<div></div>
JS形式
var myModule = angular.module("MyModule", []);
myModule.directive("hello", function() {
return {
restrict: 'AEMC',
template: '<div>Hi everyone!</div>',
replace: true
}
});
说明
restrict | 名称 | HTML形式 |
---|---|---|
E | 元素 | |
A | 属性 | |
C | 样式表 | |
M | 注释 |