用gulp-ng-html2js 把Angularjs的template html文件压缩到一个js中后,怎么引用html模板?

新手上路,请多包涵

我用angular.js 1.5x 开发项目的时候,使用gulp压缩打包,其中用到了gulp-ng-htmls2js插件,把template 的html文件压缩到一个js文件中,然后我就不知道怎么引用template html模板了。
app.js

app.config(function($stateProvider,$urlRouterProvider) {
    $stateProvider
        .state({
            name: 'tabs.home.news',
            url: '/news',
            template: './home/news/news.html',
            controller: 'newsCtrl'
        });
    $urlRouterProvider.when('','/tabs/home/news');  // 默认跳转

})

home/news/news.html

<view class="view">
    <content class="content">
        Hello world  
    </content>
</view>

压缩后的js文件

(function(module) {
try {
  module = angular.module('MyAwesomePartials');
} catch (e) {
  module = angular.module('MyAwesomePartials', []);
}
module.run(['$templateCache', function($templateCache) {
  $templateCache.put('./commonInfo/commonInfo.html',
    '<view class="view">
    <content class="content">
        Hello world  
    </content>
</view>');
}]);
})();

现在我要怎么把压缩后的html模板引到app.js文件中呢?
不做任何修改的时候,会报/home/news/news.html文件找不到,因为我是打包到了dist文件夹下,所以在dist文件夹下是没有/home/news/news.html文件的
clipboard.png

阅读 2.4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题