代码之家  ›  专栏  ›  技术社区  ›  Al Ex Tsm

Ui网格:通过承诺类型获取cellTemplate错误?

  •  0
  • Al Ex Tsm  · 技术社区  · 7 年前

    我设置了gridOptions。columnDefs[列]。cellTemplates价值承诺:

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

    enter image description here

    来自ui网格中的以下代码块。js文件:

    enter image description here

    这只能通过承诺实现。如果我执行以下操作,则模板加载良好:

    cellTemplate:'/templates/customTempTest.html'
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Brian    7 年前

    $.get 是jQuery。不确定示例中为什么会出现这种情况。如有必要,最好不要将两者混合。但是,说到点子上-

    如果需要这样做,而仅仅指定路径不起作用(我不知道为什么),那么这将起作用:

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

    我用叉子叉了一记 demo 您在评论中发布并修改了它。在$http解析之后,我还有一个简单的控制台输出,只是为了清楚地了解事情发生的时间。

    下面是工作plunk: https://plnkr.co/edit/0WTpaYMc4zejIpeaagkW?p=preview