Angular: Compile is not defined
Angular: Compile is not defined
我已经面临一个问题很长时间了。你能帮我解决这个问题吗。实际上,我想在很多地方使用table指令。所以我创建了一个指令,并将angular UI网格绑定到其中。但我遇到了编译错误。
错误:angular.min.js:102 ReferenceError:编译未定义
但我可以加载网格内容
我在这里做错了什么?
HTML
<div ng-controller="ctrl1 as two">
<ltcg-table><ltcg-table>
</div>
<div ng-controller="ctrl2 as two">
<ltcg-table><ltcg-table>
</div>
JS
myApp.directive('ltcgTable', function($compile) {
return {
restrict: 'E',
transclude: true,
replace: false,
scope: { },
controller: Controller,
controllerAs: 'Controller',
bindToController: true,
compile: compile
}
});
compile
函数(compile: compile
的第二部分)未定义。它应该是以下形式的函数:
function compile(tElement, tAttrs, transclude) { ... }
所以,试着这样定义指令:
myApp.directive('ltcgTable', function($compile) {
return {
restrict: 'E',
transclude: true,
replace: false,
scope: { },
controller: Controller,
controllerAs: 'Controller',
bindToController: true,
compile: function(tElement, tAttr, transclude) {
//do some stuff here
}
}
});
或者,如果您不需要做任何特殊的事情,并且网格按原样工作,只需将compile
字段排除在方向规范之外。
相关文章:
- reactRedux is not defined
- ReferenceError: not defined
- ReferenceError: cordova is not defined @ng-cordova.min.js:7
- jQuery is not defined - WordPress footer.php
- GAPI Is Not Defined
- Page_ClientValidate is not defined
- ReferenceError: $firebase is not defined
- ReferenceError: crimeID is not defined
- AngularJS: $scope is not defined?
- ajaxUrl is not defined
- WebView: Uncaught ReferenceError: Android is not defined
- ReferenceError SetInterval not defined
- ReferenceError: yes is not defined
- ReferenceError "not defined"
- Soundcloud API ReferenceError: $ is not defined (JavaScript)
- Angular: Compile is not defined
- nodeJS phantom ReferenceError: Promise is not defined
- observableArray is not defined
- Uncaught ReferenceError trapArea/Per is not defined
- ReferenceError: xmlhttp is not defined