我使用templateUrl,效果很好!
app.directive('myDir',function() { return { templateUrl: 'partials/directives/template.html' }; };
但是……当我对这些模板进行更改时,它不会更新.在开发过程中,这不是一个大问题,因为我知道更新了什么,可以手动清除缓存.
解决方法
据我所知,你有两个选择 –
>使用$cacheFactory服务删除旧缓存
获取模板后,Angular会将其缓存在默认的$templateCache服务中
// Please note that $cacheFactory creates a default key '$http' var cache = $cacheFactory.get('$http'); // The remove() function removes a key-value pair from the cache,// if it’s found. If it’s not found,then it just returns undefined. cache.remove(your url);
>使用文件版本控制每次更改时重命名文件 – 即如果您的文件的第一个版本是template-1.0.1.html,则在进行一些代码更改时将其重命名为template-1.0.2.html,依此类推.这样,每次进行一些更改时都会下载新文件.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。