扫码关注官方订阅号
这些请求很明显暴露了模版,有办法隐藏或者不请求嘛?!
光阴似箭催人老,日月如移越少年。
angular.module('app.ui', []).run(["$templateCache", function($templateCache) { $templateCache.put("template/index.html", '<p><input type="text" ng-model="id">\ <a href="/TEST/{{id}}.html">TEST/{{id}}.html</a>\ <a href="/test/{{id}}.xml">test/{{id}}.xml</a>\ <a href="/test/{{id}}.json?a=test">test/{{id}}.json?a=test</a>\ <a href="/test/{{id}}.css">test/{{id}}.css</a>\ </p>'); }]);
把html代码放入模板里面
非常感谢 @jets 的回答!然后,自己经过查询发现了另一个避免请求的方法,就是使用script标签引入
<script type="text/ng-template" id="template_id"> <p>这是script标签获取模板文件的方式</p> </script>
然后在配置路由时,指定templateUrl为模版的id属性,就像这样:
// 前面省略N行js代码 $routeProvider.when('/index', { controller: 'control', templateUrl: 'template_id' });
完毕!
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
把html代码放入模板里面
非常感谢 @jets 的回答!
然后,自己经过查询发现了另一个避免请求的方法,就是使用script标签引入
然后在配置路由时,指定templateUrl为模版的id属性,就像这样:
完毕!