使用gulp-angular-templatecache将HTML组合到template.js中,获取$ injector模块不可用错误

时间:2015-07-15 18:45:16

标签: javascript angularjs templates gulp angularjs-templates

我使用gulp-angular-templatecache抓取所有部分HTML模板文件,并将它们合并到1个template.js文件中。

我能够完成的第一部分,我可以运行我的Gulp任务,并创建templates/templates.js

templates.js:

angular.module("templates").run(["$templateCache", function($templateCache) {$templateCache.put("beta.html","<div class=\"login-container\" ng-controller=\"BetaCtrl as beta\">\n    <section class=\"login-form-block\">\n        <header>\n            <div class=\"tickertags-logo-big\"></div>\n            <h1>Welcome to the TickerTags beta! Enter the email address where your beta invitation was sent below. We will send you an email with your temporary password.</h1>\n        </header>\n\n        <div class=\"login-form\">\n\n            <form name=\"loginForm\" ng-submit=\"beta.beta(credentials)\" novalidate>\n\n                <div class=\"login-alert\" ng-class=\"{ hideLoginMsg: beta.hideMessage == true }\">{{ beta.message }}</div>\n\n                <input type=\"email\"\n                       id=\"email\"\n                       placeholder=\"Email\"\n                       name=\"email\"\n                       ng-model=\"credentials.email\">\n\n                <button type=\"submit\" class=\"login-btn\">Email Password</button>\n            </form>\n\n            <p class=\"terms-of-use-line\">By signing up you agree to our <a href=\"assets/files/tickertags-terms-of-use.pdf\" target=\"_blank\">Terms of Use</a> and <a href=\"assets/files/privacypolicy.pdf\" target=\"_blank\">Privacy Policy</a></p>\n\n        </div>\n    </section>\n</div>\n");

现在我已经在我的索引中正确链接到templates.js文件:

<script src="templates/templates.js"></script> <<--
<script src="authentication/authFactory.js"></script>
<script src="help/helpController.js"></script>
etc...

我已将其包含在主应用模块中:

var app = angular.module('tickertags', [
    'ui.router',
    'templates',  // <--
    'authFactory',
    'betaController',
    'passResetController',
    'loginController',
    'apiFactory',
    'scopeFactory',
    etc...

然而仍然出现此错误: https://docs.angularjs.org/error/ $注射器/ NOMOD?P0 =模板

  

错误:$ injector:nomod   模块不可用

关于我为何会看到这一点的想法?

0 个答案:

没有答案