0
我在我的應用程序中有三個html partials,我正在使用gulp模板緩存創建一個角度模塊。gulp-angular-templatecache - 合併多個html部分
HTML文件名:
- dropdown.html
- 下拉-select.html
- 下拉-multiselect.html
咕嘟咕嘟任務:
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'));
});
後執行上述吞嚥任務。它產生下面的角模塊
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' +
'');
}]);
請讓我知道如何去做。