2

したがって、私の app.module には、実際にはテンプレートの html 要素ディレクティブを格納するディレクトリであるインジェクターがいくつかあります。問題は、カルマがディレクトリが利用できないと不平を言っていることです。カルマをロードまたは取得して、注入された依存関係を無視するにはどうすればよいですか?

特定のものは次のとおりです: templatesprovider-formcheckout-form

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
});
};
4

1 に答える 1

1

Angular の依存関係は常にモジュールであり、フォルダーに依存することはできません。そのため、これがブラウザで機能している場合は、html テンプレートを javascript にプリコンパイルし、$templateCacheモジュール内に (カルマが探している名前で) 直接入力するビルド ツールがあると思います。

この場合、別の JavaScript ファイルが作成されている可能性が高く、メインのアプリ コードの前に (ただし、Angular の後に) Karma にロードしたことを確認する必要があります。

ファイルにロードしているスクリプトを確認しindex.htmlます (見つけにくい場合は、Chrome 開発者ツールのネットワークまたはソース タブを参照してください)。

于 2014-08-09T23:11:52.613 に答える