所以在我的app.module中,我有一些注入器,它们实际上是存储模板的html元素指令的目录。问题是业力抱怨目录不可用。如何加载或获取业力以忽略注入的依赖项?
特别是:模板,提供商形式,结帐表单
var app = angular.module("DoctiblePreTreatment", ['ngDialog', 'ngResource', 'ngRoute', 'ui.select2', 'templates', 'provider-form', 'checkout-form', 'ui.mask', 'widget-filters', 'focus', 'ui.bootstrap', 'ngGrid', 'google-maps', 'angularFileUpload', 'angularPayments', 'angular-loading-bar', 'ngAnimate', 'loader']);
错误:
Error: [$injector:modulerr] Failed to instantiate module DoctiblePreTreatment due to:
Error: [$injector:modulerr] Failed to instantiate module templates due to:
Error: [$injector:nomod] Module 'templates' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
karma.conf.js文件
// Karma configuration
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '/Users/giowong/rails_project/doctible_pre_treatment/',
// testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'app/assets/components/angular/angular.js',
'app/assets/components/angular-mocks/angular-mocks.js',
'app/assets/components/angular-resource/angular-resource.js',
'app/assets/components/ngDialog/js/ngDialog.js',
'app/assets/components/angular-route/angular-route.js',
'app/assets/components/jquery-1.11.1.min.js',
'app/assets/javascripts/main.js',
'app/assets/javascripts/**/**/*.js',
'app/assets/javascripts/*.js',
'spec/javascripts/*.js'
],
// list of files / patterns to exclude
exclude: ['app/assets/javascripts/angular-google-maps.min.js'
],
// web server port
port: 8080,
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Chrome'],
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: true
});
};
答案 0 :(得分:1)
Angular依赖项始终是模块,您不能依赖于文件夹。因此,如果这在您的浏览器中有效,我会假设您已经构建了将html模板预编译为javascript的工具,并直接在模块中填充$templateCache
(具有karma正在寻找的名称)。
如果是这种情况,很可能会创建另一个javascript文件,您需要确保在主应用程序代码之前加载到业力中(但是在角度之后)。
检查您在index.html
文件中加载的脚本(如果您无法找到它,可以查看Chrome开发者工具的网络或来源标签)。