在我来到这里之前,我确实阅读了这个帖子:https ://github.com/angular-ui/ui-grid/issues/2078 ,但仍然没有找到解决方案。
非常相似的问题:
angular.module('XXX')
directive(
'myDirective', [function() {
return {
restrict: 'E',
scope: {data: '='},
templateUrl: 'myTemplate.html',
compile: function() {
return {
pre: function(scope, elem) {
var cT = '<div>Details</div>';
scope.gridOptions = {
columnDefs: [{ field: 'myField', displayName:
'myFieldName', cellTemplate: 'myCellTemplate.html'}]
};
}
}
}
}]);
我完全复制cT
到'myCellTemplate.html'并尝试加载它,但没有工作,但如果我使用内联cT
它工作正常。我厌倦了将 'myTemplate.html' 更改为 'myCellTemplate.html'templateUrl:
以查看指令是否可以成功加载 html,它实际上也在工作。所以我想知道compile:
->pre:
函数是否有不同的路径,所以它在当前路径中找不到“myCellTemplate.html”?
有什么想法吗?
更新
在我将路径更改为“/partial/.../myCellTemplate.html”后工作