当前位置:Gxlcms > PHP教程 > javascript-angular控制台的模版请求

javascript-angular控制台的模版请求

时间:2021-07-01 10:21:17 帮助过:28人阅读

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

回复内容:

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

 angular.module('app.ui', []).run(["$templateCache",
  function($templateCache) {
    $templateCache.put("template/index.html", 
      '\
        TEST/{{id}}.html\
        test/{{id}}.xml\
        test/{{id}}.json?a=test\
        test/{{id}}.css\
      ');
  }]);

把html代码放入模板里面

非常感谢 @jets 的回答!
然后,自己经过查询发现了另一个避免请求的方法,就是使用script标签引入

然后在配置路由时,指定templateUrl为模版的id属性,就像这样:

// 前面省略N行js代码
$routeProvider.when('/index', {
  controller: 'control',
  templateUrl: 'template_id'
});

完毕!

人气教程排行