[英]link function inside angularjs directive not working
我在这里有一个js小提琴
指令既不呈现,也不调用该指令的链接函数。
代号:JS
(function() {
var app = angular.module("directives", []);
app.directive("mySample", function() {
return {
restric: "E",
replace: true,
template: "<div>sample directive</div>",
link: function(scope, elem, attrs) {
console.log(elem);
}
};
});
}());
HTML:
<body ng-app="directives">
<my-sample></my-sample>
</body>
您的指令具有restric
属性,应在该位置进行restrict
(缺少最后的't')。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.