当您有一个文件 app.js 和许多模块时,像下面的代码片段那样在 JavaScript 中嵌入 HTML 是不可维护的。
应用程序.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进行快速检索。