自定义指令

Oranq 2016-05-31

为了让AngularJS能够调用我们的指令,需要修改指令定义中的restrict设置。这个设置告诉AngularJS在编译HTML时用那种声明格式来匹配指令定义,我们可以指定一个或者多个格式
元素(E)、属性(A)、类(C)、注释(M)

angular.module('myApp', [])
.directive('myDirective', function() {
return {
restrict: 'EAC',
replace: true,
template: '<a href="http://google.com">Click me to go to Google</a>'
};
});

相关推荐