首页 > angular 控制台的模版请求

angular 控制台的模版请求

这些请求很明显暴露了模版,有办法隐藏或者不请求嘛?!


 angular.module('app.ui', []).run(["$templateCache",
  function($templateCache) {
    $templateCache.put("template/index.html", 
      '<div><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>\
      </div>');
  }]);

把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'
});

完毕!

【热门文章】
【热门文章】