I have a very large modularized AngularJS Application. I setup Grunt to create a single JS file from the multiple html files using html2js.
html2js: {
options: {
base: 'dol',
module: 'dol.templates',
singleModule: true,
useStrict: true,
htmlmin: {
collapseBooleanAttributes: true,
collapseWhitespace: true,
removeAttributeQuotes: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
}
},
main: {
src: ['app/modules/reporting/views/*.html'],
dest: 'tmp/templates.js'
}
},
I then run concat on all of my js files and that newly created templates.js file:
concat: {
options: {
separator: ';'
},
dist: {
src: ['tmp/*.js', 'app/app.js', 'app/app.controller.js', 'app/common/directives/directives.js', 'app/app.factory.js', 'app/modules/reporting/controllers/reports.controller.js', 'app/modules/reporting/reports.routes.js', 'app/xenon.custom.js'],
dest: 'dist/app.js'
}
},
I now have one file with all of my js files and html files: app.js
I am referencing that dist/app.js file in my index.html
The issue I am having is inside my application I reference some of the HTML files like such:
// Layout Related Directives
directive('reportsSummary', function () {
return {
restrict: 'E',
templateUrl: appHelper.templatePath('modules/reporting/views/reportssummary.view')
};
}).
directive('reportsSidebarMenu', function () {
return {
restrict: 'E',
templateUrl: appHelper.templatePath('modules/reporting/views/reports.sidebar.menu')
};
}).
directive('reportsFooter', function () {
return {
restrict: 'E',
templateUrl: appHelper.templatePath('modules/reporting/views/reports.footer')
};
});
When I run my deployed application, I get an error stating that it cannot find those files. When I run my app locally, it runs fine because the files reside in the proper paths.
Question is: When deploying the app, how do I reference those html files in my code since they now reside in dist/app.js
I also reference the html files in my ui-router: (function () { 'use strict';
angular
.module('dol')
.config(reportsConfig);
reportsConfig.$inject = ['$stateProvider', '$urlRouterProvider'];
function reportsConfig($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/reports');
$stateProvider.state('reports',
{
url: '/reports',
templateUrl: 'app/modules/reportspage/views/reports.view.html',
controller: 'reportsController'
});
}
})();