2
我写了一个基本的吞咽角嵌入模板任务,将所有指令与模板URL转换为模板。如果我在我的指令模板URL中使用相对路径,则可以看到使用此任务的转换正常进行。但是,当我将绝对路径添加到我的指令html中时,则此任务不会附加html模板。任务完成后,我仍然看到模板URL。如何添加基本路径给吞噬角嵌入模板
在文档base path for angular embed template我已经看到这个任务提供了一个基本路径,它将转换所有的模板URL的基本浴。
这是我的尝试:
directive.js:
(function() {
'use strict';
angular.module('testApp')
.directive('test', test);
function test() {
return {
restrict: 'E',
templateUrl: basePath+'templates/test.html'
}
}
})();
gulpfile.js:
var gulp = require('gulp');
var embedTemplates = require('gulp-angular-embed-templates');
gulp.task('js:build', function() {
gulp.src('src/app/**/*.js')
.pipe(embedTemplates({
options:{basePath:'/'}
}))
.pipe(gulp.dest('dist'));
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['js:build']);