[英]AngularJS view build for RequireJS?
Angular对于.html局部视图具有很好的视图注入功能,但对于生产而言并不是最佳性能。
我看过一些指令,例如angularui使用模板缓存,例如:
angular.module("template/alert/alert.html", []).run(["$templateCache", function($templateCache) {
$templateCache.put("template/alert/alert.html",
"<div class='alert' ng-class='\"alert-\" + (type || \"warning\")'>\n" +
"<button ng-show='closeable' type='button' class='close' ng-click='close()'>×</button>\n" +
"<div ng-transclude></div>\n" +
"</div>\n" +
"");
}]);
是否有针对grunt或requirejs的构建过程,您可以执行以下操作:
// ngview will be used in production
// mode to map view dependencies but
// not used in development mode
define(['myapp', 'ngview!home'], function(){ ... });
然后在生成的文件中将生成templateCache对象。
有什么想法吗?
尽管它不是特定于Require的,但有一个针对grunt的任务称为html2js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.