【发布时间】:2016-11-16 23:54:36
【问题描述】:
当你有一个文件 app.js 和许多模块时,像下面的代码 sn-p 在 JavaScript 中嵌入 HTML 是不可维护的。
app.js
app.config(['$routeProvider', function($routeProvider){
$routeProvider.when('/first',{
templateUrl: 'partial/first.html',
controller: 'FirstCtrl'
});
}]).run(function($templateCache){
$templateCache.put('partial/first.html', '<p>Hundred lines of Html</p>');
});
是否可以将这 100 个 LoC 从 $templateCache.put(...) 迁移到 Html 文件中,就像我们使用 templateUrl 而不是模板一样?或者建议另一种方法来实现这一点,因为我正在失去对代码的控制。我想使用 $templateCache 进行快速检索。
【问题讨论】:
标签: javascript html angularjs angular-template angular-templatecache