search

Home  >  Q&A  >  body text

angular.js - The way angular loads templates

$scope.initData = function() {

    //预加载项
    $templateCache.removeAll(); //移除所有模板内容,释放内存
    $templateCache.put('templates/main/decorateChooseTem.html', utils.getTemplates('templates/main/decorateChooseTem.html')); //列表选择模板
    $templateCache.put('templates/main/houseInputTem.html', utils.getTemplates('templates/main/houseInputTem.html')); //小区自动完成模板
    $templateCache.put('templates/main/numberInputTem.html', utils.getTemplates('templates/main/numberInputTem.html')); //输入数字模板
    $templateCache.put('templates/main/descosTem.html', utils.getTemplates('templates/main/descosTem.html'));
    $templateCache.put('templates/main/descontactTem.html', utils.getTemplates('templates/main/descontactTem.html'));

I use preloaded templates, but $templateCache.put(,); this method has drawbacks. When immobile for a long time, it will let you reload. Is there any good way to load it? I’m just learning, it’s best to have a demo

淡淡烟草味淡淡烟草味2754 days ago568

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-05-15 16:57:00

    You can try itng-include.

    reply
    0
  • Cancelreply