AngularJS指令学习进阶

AngularJS指令学习进阶

var app = angular.module('myApp', []); app.directive('myDirective', function(){ return { restrict: 'EACM',//告诉AngularJS这个指令在DOM中以何种形式被声明,默认为A priority: Number,//优先级参数(值为数值),数值越大,优先级越高,默认为0 terminal: Boolean,//true或者false,告诉AngularJS是(true)否(false)停止运行当前元素上比本指令优先级低的指令 template: String or Template Function,//模板 templateUrl: String,//模板URL replace: Boolean,//值为true,代表模板会替换掉调用该指令的元素 scope: Boolean or Object,//指令作用域 transclude: Boolean,//true,结合ng-transclude,在该指令中嵌入内容 controller: String or function($scope, $element, $attrs, $transclude, otherInjectables){...},//指令控制器 controllerAs: String,//用来设置控制器的别名 require: String,//将控制器注入到其值所指定的指令中 link: function(scope, element, attrs){...}, compile: function(){} }; });

代码稍长,请自行打开

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/12cc0db3d8bab5ecfb3767c0eb2ab2b7.html