AngularJS 弹出框未在指令内呈现
AngularJS Popover not rendering inside a directive
编辑: 这是我的问题的补充:
http://plnkr.co/edit/4U6XZKewA3EdFmHeqxwF?p=preview
(UI 行为很好,弹出窗口中没有内容,但我无法重现我在开发环境中收到的错误消息。)
我正在尝试根据自定义指令中的模板调用 angular ui-bootsrap 弹出窗口。可悲的是,它不起作用。当我不使用 popover-template 时,根本没有问题。我一直在寻找这个问题的根本原因...如果你们有任何想法,我们将不胜感激。
错误信息:
22/07/2015-11:27:43::[global]> TypeError: element.parent is not a function
at queueAnimation (http://localhost:3000/bower_components/angular-animate/angular-animate.js:2101:26)
at Object.push (http://localhost:3000/bower_components/angular-animate/angular-animate.js:2053:16)
at Object.enter (http://localhost:3000/bower_components/angular/angular.js:5181:31)
at http://localhost:3000/bower_components/angular-bootstrap/ui-bootstrap-tpls.js:3052:24
at publicLinkFn (http://localhost:3000/bower_components/angular/angular.js:7415:29)
at http://localhost:3000/bower_components/angular-bootstrap/ui-bootstrap-tpls.js:3050:43
at processQueue (http://localhost:3000/bower_components/angular/angular.js:14567:28)
at http://localhost:3000/bower_components/angular/angular.js:14583:27
at Scope.$eval (http://localhost:3000/bower_components/angular/angular.js:15846:28)
at Scope.$digest (http://localhost:3000/bower_components/angular/angular.js:15657:31)
指令模板 app/directive.html :
<span ng-repeat="monitoringResult in data">
<a popover-template="'app/popoverStatusTemplate.html'" popover-trigger="mouseenter">
<span>Data 1</span>
</a>
</span>
指令:
(function() {
'use strict';
angular
.module('app')
.directive('directiveOne', directiveOne)
/** @ngInject */
function directiveOne($http) {
/...../ // Do Stuff
}
return {
restrict : 'EA',
link : link,
scope: {
limit: '='
},
templateUrl : 'app/directive.html'
};
}
})();
确保您的模板包含在标签中,以便它可以被注入,即从您 plnkr 中的示例,替换为 popoverStatusTemplate.html
:
popover Template
与:
<span>popover Template</span>
编辑: 这是我的问题的补充: http://plnkr.co/edit/4U6XZKewA3EdFmHeqxwF?p=preview
(UI 行为很好,弹出窗口中没有内容,但我无法重现我在开发环境中收到的错误消息。)
我正在尝试根据自定义指令中的模板调用 angular ui-bootsrap 弹出窗口。可悲的是,它不起作用。当我不使用 popover-template 时,根本没有问题。我一直在寻找这个问题的根本原因...如果你们有任何想法,我们将不胜感激。
错误信息:
22/07/2015-11:27:43::[global]> TypeError: element.parent is not a function
at queueAnimation (http://localhost:3000/bower_components/angular-animate/angular-animate.js:2101:26)
at Object.push (http://localhost:3000/bower_components/angular-animate/angular-animate.js:2053:16)
at Object.enter (http://localhost:3000/bower_components/angular/angular.js:5181:31)
at http://localhost:3000/bower_components/angular-bootstrap/ui-bootstrap-tpls.js:3052:24
at publicLinkFn (http://localhost:3000/bower_components/angular/angular.js:7415:29)
at http://localhost:3000/bower_components/angular-bootstrap/ui-bootstrap-tpls.js:3050:43
at processQueue (http://localhost:3000/bower_components/angular/angular.js:14567:28)
at http://localhost:3000/bower_components/angular/angular.js:14583:27
at Scope.$eval (http://localhost:3000/bower_components/angular/angular.js:15846:28)
at Scope.$digest (http://localhost:3000/bower_components/angular/angular.js:15657:31)
指令模板 app/directive.html :
<span ng-repeat="monitoringResult in data">
<a popover-template="'app/popoverStatusTemplate.html'" popover-trigger="mouseenter">
<span>Data 1</span>
</a>
</span>
指令:
(function() {
'use strict';
angular
.module('app')
.directive('directiveOne', directiveOne)
/** @ngInject */
function directiveOne($http) {
/...../ // Do Stuff
}
return {
restrict : 'EA',
link : link,
scope: {
limit: '='
},
templateUrl : 'app/directive.html'
};
}
})();
确保您的模板包含在标签中,以便它可以被注入,即从您 plnkr 中的示例,替换为 popoverStatusTemplate.html
:
popover Template
与:
<span>popover Template</span>