WorthyD
5/25/2017 - 2:50 PM

Angular Task Runner Config.

Angular Task Runner Config.

//npm install grunt-html2js --save-dev

grunt.registerTask('build-htmljs', ['html2js', 'uglify:htmljs', 'notify:templates']);

///html2js grunt task
module.exports = {
 options: {
        // custom options, see below
        htmlmin: {
            collapseBooleanAttributes: false,
            collapseWhitespace: false,
            removeAttributeQuotes: false,
            removeComments: true,
            removeEmptyAttributes: false,
            removeRedundantAttributes: false,
            removeScriptTypeAttributes: false,
            removeStyleLinkTypeAttributes: false
        },
        base: 'src/Web/',
    },

    main: {
        src: ['src/Web/Scripts/App/**/*.html'],
        dest: 'src/Web/Scripts/dist/app.templates.js'
    }
}
(function () {
    'use strict';

    angular.module('app', [
        'app.core',
        ....
        'templates-main'


    ]);
})();
///Example route config and generated code. Note that 'Scripts/App/Dashboard/dashboard.html'  must 100% match this includes letter casing.
{
    url: '/',
    config: {
        templateUrl: 'Scripts/App/Dashboard/dashboard.html',
        controller: 'Dashboard',
        controllerAs: 'vm',
        title: 'dashboard',
        settings: {
            nav: 1,
            content: 'Dashboard'
        }
    }
},
///////////This is a generated in a different file file, just showing example.

angular.module('templates-main', ['Scripts/App/Approval/dashboard.html']);

angular.module("Scripts/App/Approval/dashboard.html", []).run(["$templateCache", function($templateCache) {
  $templateCache.put("Scripts/App/Approval/dashboard.html", '<div></div>')
}]);