0

我设置gridOptions.columnDefs [COL] .cellTemplates值作为承诺:Ui网格:通过诺言类型错误获取cellTemplate?

cellTemplate: $http.get('/templates/customTempTest.html') 

模板发现返回状态200 OK。从代码UI-grid.js文件中的下列块

enter image description here

::但我得到以下错误

enter image description here

这只能通过承诺发生。如果我按照以下步骤进行模板加载:

cellTemplate:'/templates/customTempTest.html' 
+0

你为什么叫jQuery的'$ .get'? –

+0

@MaximShoustin我只是遵循以下示例:http://brianhann.com/6-ways-to-take-control-of-how-your-ui-grid-data-is-displayed/ –

回答

0

$.get是jQuery。不知道为什么在示例中显示。如果需要,最好不要混合两者。但是,到了点 -

如果你需要做到这一点,只是指定路径将无法正常工作(我不知道为什么),那么这将工作:

{ 
    name: 'email', 
    cellTemplate: $http.get('emailTemplate.html') 
        .then(function(r){ return r.data }) } 
} 

我一个分叉从你在评论中发布的demo中选择并修改它。在$ http解析之后,我还有一个简单的控制台输出,用于清楚事情发生的时间。

这里是工作普拉克: https://plnkr.co/edit/0WTpaYMc4zejIpeaagkW?p=preview