我已经看到过这个过程,我试图实现一个封装函数,但是它打破了我的指令。没有封装它的作品。有没有人以前做过或有人知道为什么它违反了指令?如何将JS封装函数封装在指令中
https://jsfiddle.net/ciderman/a0n9h0ar/1/
(function() {
myApp.directive('myPerfectDirective', function(){
return{
restrict: 'E',
scope: {
data: '='
},
template: '<p>my perrrrrrfeccct directivve</p>',
templateUrl: 'book-widget.html'
}
});
});
我认为这个问题是你是不是调用该函数,它应该()(){....})()'验证把最后一个'()'括起来 –