【问题标题】:how to check if a spcific url is alreayd in the $templateCache in angular如何检查特定的 url 是否已经在 $templateCache 中
【发布时间】:2013-04-24 13:07:51
【问题描述】:

有没有办法检查给定的 url 是否已经存在于 AngularJS 的 $templateCache 中?

为了提供一些上下文:我做了一个指令,在等待加载 ngInclude templateUrl 时插入一个加载器,然后播放动画,如果内容只是从缓存而不是从服务器获取。

【问题讨论】:

    标签: caching angularjs angularjs-ng-include


    【解决方案1】:

    您可以使用下面的代码来检查 url 是否存在于模板缓存中

    $templateCache.get('stringurl');
    

    【讨论】:

    • 谢谢,我正在尝试这样做,但只是在表达上。一旦我确定这应该起作用,添加一个范围。$eval(myExpr) 就可以了。
    猜你喜欢
    • 1970-01-01
    • 2011-04-21
    • 1970-01-01
    • 1970-01-01
    • 2017-10-05
    • 1970-01-01
    • 2016-08-11
    • 2017-08-09
    • 1970-01-01
    相关资源
    最近更新 更多