【发布时间】:2015-05-18 05:41:34
【问题描述】:
我的应用程序中有三个 html 部分,我正在使用 gulp 模板缓存创建一个角度模块。
HTML 文件名:
- dropdown.html
- 下拉选择.html
- 下拉多选.html
Gulp 任务:
gulp.task('dropdown', function( )
{
return gulp.src('modules/dropdown/*.html')
.pipe(plugins.plumber())
.pipe(plugins.templatecache({
output: 'dropdown_template.js',
moduleName: 'dropdown',
prepend: 'dropdown.html', // Need to replace with actual file name's
strip: 'views/'
}))
.pipe(gulp.dest('build/js/templates'));
});
执行上述 gulp 任务后。它生成下面的角度模块
angular.module("dropdown").run(['$templateCache', function(a) { a.put('dropdown.html', '<div class="dropdown" ng-transclude="parent"></div>\n' +
''); // 1st html
a.put('dropdown.html', '<div ng-transclude="1"></div>\n' +
''); //2nd html - name is wrong it should be dropdown-select.html
a.put('dropdown.html', '<div class="dropdown-menu dropdown-menu--{{ position }}">\n' +
'');// 3rd html - name is wrong it should be dropdown-multiselect.html
}]);
a.put('dropdown.html') 正在为所有 3 个 html 生成。但我需要实际的文件名而不是 dropdown.html。如下所示
angular.module("dropdown").run(['$templateCache', function(a) { a.put('dropdown.html', '<div class="dropdown" ng-transclude="parent"></div>\n' +
'');
a.put('dropdown-select.html', '<div ng-transclude="1"></div>\n' +
'');
a.put('dropdown-multiselect.html', '<div class="dropdown-menu dropdown-menu--{{ position }}">\n' +
'');
}]);
请告诉我怎么做。
【问题讨论】: