使用gulp-angular-templatecache将HTML合并到template.js中,得到$injector
Using gulp-angular-templatecache to combine HTML into template.js, getting $injector Module Unavailable error
我使用gulp-angular-templatecache,抓取我所有的部分HTML
模板文件,并将它们组合成一个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 =模板
错误:美元注入器:nomod模块不可用
知道我为什么会看到这个吗?
因为该模块没有正确声明。
你需要在你的应用程序的某个地方声明模板模块,像这样:angular.module("templates", []);
或使用options.standalone = true
在gulp插件
来自文档:
注意:这个插件默认不会创建一个新的AngularJS模块,而是使用一个名为templates的模块。如果您想创建一个新模块,请设置选项。
相关文章:
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 不再使用innerHTML进行AJAX响应.(代码未得到响应)
- 我能得到正确的格式吗
- 为什么我得到错误IE修剪方法是't支持
- 两个指令创建新的继承的和隔离的作用域-元素得到哪个
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Ajax请求返回空的数据字符串,但首先得到了正确的数据
- 预期响应包含一个对象,但在angular js中得到一个数组错误
- Android在webview中加载带有javascript的html文件,得到Uncaught ReferenceEr
- 微风得到的是实体而不是对象的集合
- 错误:$injector:modulerr模块错误(我的第一个SPA应用程序)
- spring和angularJS(我得到了类似HTTP状态404的错误)
- I'我得到这个.get()在ember中未定义
- 为什么我得到错误:$injector:unp未知提供程序
- 为什么我在这里得到Angular$injector:modulerr错误?使用1.5β
- 为什么我得到$injector:unpr(未知提供商)在这个单页应用程序
- 使用gulp-angular-templatecache将HTML合并到template.js中,得到$injector
- angular.js:4640Uncaught Error: [$injector:modulerr]得到这个错误
- 为什么我得到'错误:$injector:modulerr模块错误'在这个基本控制器中
- 我在angular js Uncaught错误中得到了这样的错误:[$injector:modulerr]