大佬教程收集整理的这篇文章主要介绍了angularjs – 更改$includeContentRequested上的源URL,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
app.run(function ($rootScopE) { $rootScope.$on('$includeContentrequested',function (event,url) { console.log(event); console.log(url); }); });
现在我需要将“templates / incs / includedPartial.html”的url更改为“templates / incs / includedPartial.html?cache_version = 1_1”,然后将该部分包含在新的链接中.
app.factory( "cacheBusterFactory",[ "VERSION",function( VERSION ) { return { request: function( config ) { if( config.url.indexOf( ".html",config.url.length - ".html".length ) !== -1 ) { config.url += "?v=" + VERSION.toString(); } return config; } }; } ] );
在这种情况下,“VERSION”是每次部署时更改的角常数:
app.constant( "VERSION",0.1 );
添加缓存无效化就像:
.config( [ "$httpProvider",function( $httpProvider ) { $httpProvider.interceptors.push( "cacheBusterFactory" ); } ] )
正如你可以看到,我只拦截.html文件,因为那些是我需要添加缓存破坏的唯一的.您当然可以扩展或重建“cacheBusterFactory”来满足您的需要.
以上是大佬教程为你收集整理的angularjs – 更改$includeContentRequested上的源URL全部内容,希望文章能够帮你解决angularjs – 更改$includeContentRequested上的源URL所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。