如何删除模块找不到错误的角度? [英] How to remove module not found error in angular?
问题描述
我把这里控制器的一个简单的例子。
http://plnkr.co/edit/dplJ6sf4kgiwJ5pXu4GE?p=$p$ PVIEW
和我想测试一下。我是能够在网上测试我的控制器,该控制器
下面是我的code在线测试我的控制器
http://plnkr.co/edit/xzvhXHPoUdulOM9clOkQ?p=$p$pview一>
但是当我尝试到我的电脑我的测试用例上运行同样的工作是失败的
我得到这个错误
模块'app.home不可!你要么拼写错误的模块名称,或忘了加载它。如果注册一个模块,确保指定的依赖关系作为第二个参数。
下面是我的电脑code。
https://dl.dropbox.com/s/no901z41bza7osm/SimpleDemo.zip ?DL = 0
请运行 NPM安装以添加依赖关系。
下面是我的karma.conf.js文件
//噶配置
//生成于星期五二零一五年十二月一十八日19时53分32秒GMT + 0530(IST)module.exports =功能(配置){
config.set({ 将用于解决所有的模式//基本路径(如文件,排除)
基本路径:'',
//框架使用
//可用的框架:https://npmjs.org/browse/keyword/karma-adapter
框架:['茉莉'],
//的文件/目录模式在浏览器中加载
文件: bower_components /角/ angular.js',
bower_components / jQuery的/距离/ jquery.js和'
bower_components /角度的UI路由器/发行/角-UI-router.js',
bower_components /角嘲笑/角mocks.js',
bower_components /角资源/角resource.js',
应用程序/ *。JS',
应用程序/ ** / *。JS',
应用程序/ ** / *。HTML,
测试/ **。JS
]
//文件的列表中排除
排除:
]
// preprocess他们服务到浏览器之前匹配的文件
//用preprocessors:https://npmjs.org/browse/keyword/karma-$p$pprocessor
preprocessors:{
'应用程序/ ** / * HTML':'NG-html2js']
}, ngHtml2Js preprocessor:{
MODULENAME:'模板' }, //测试结果记者使用
//可能的值:点,进步
//可用记者:https://npmjs.org/browse/keyword/karma-reporter
记者:进步]
// Web服务器端口
端口:9876,
//使输出/禁止的颜色(记者和日志)
颜色:真,
//日志记录级别
//可能的值:config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
LOGLEVEL:config.LOG_INFO,
//启用/禁用看文件和执行测试,只要任何文件更改
autoWatch:真实,
//启动这些浏览器
//浏览器可发射:https://npmjs.org/browse/keyword/karma-launcher
浏览器:['铬'],
//持续集成模式
//如果为真,噶捕捉浏览器,运行测试,退出
singleRun:假的, //并发级别
//多少浏览器应该启动点大
并发:无限
})
}
这是我的code 测试
(函数(){ 使用严格
描述(HTTP控制器测试,函数(){ 变量$ rootScope,
$范围,
控制器
$ Q,
$ httpBackend; beforeEach(函数(){
模块(应用); 注(函数($喷油器){
$ rootScope = $ injector.get('$ rootScope');
$范围= $ rootScope $新的()。
控制器= $ injector.get('$控制器)(homeCntrl',{
$范围:$范围
})
})
})
描述('初值',函数(){
它('检查名称值',函数(){
期待(controller.message).toBeUndefined();
}) }) 它('应该是真的',函数(){
期待(真).toBeTruthy(); })
})
})()
任何更新?怎么办控制器的测试?
更新1
当我写这样说,这是不工作...检查这些文件
应用程序/ ** / *。JS',
应用程序/ *。JS',
应用程序的/ home /控制器/ *。JS',
应用程序/ ** / *。HTML,
测试/ **。JS
全code
文件: bower_components /角/ angular.js',
bower_components / jQuery的/距离/ jquery.js和'
bower_components /角度的UI路由器/发行/角-UI-router.js',
bower_components /角嘲笑/角mocks.js',
bower_components /角资源/角resource.js',
应用程序/ ** / *。JS',
应用程序/ *。JS',
应用程序的/ home /控制器/ *。JS',
应用程序/ ** / *。HTML,
测试/ **。JS
]
但是当我写这样,它完美地工作,为什么?
文件: bower_components /角/ angular.js',
bower_components / jQuery的/距离/ jquery.js和'
bower_components /角度的UI路由器/发行/角-UI-router.js',
bower_components /角嘲笑/角mocks.js',
bower_components /角资源/角resource.js',
应用程序/家庭/ *。JS',
应用程序/ app.js,
应用程序的/ home /控制器/ *。JS',
应用程序/ ** / *。HTML,
测试/ **。JS
]
修改
homeCntrl
到homecntrl
块引用>在这行你route.js:
控制器:'homeCntrl如家
I make a simple example of controller here .
http://plnkr.co/edit/dplJ6sf4kgiwJ5pXu4GE?p=preview
and I want to test the controller .I am able to test my controller online
Here is my code to test my controller online http://plnkr.co/edit/xzvhXHPoUdulOM9clOkQ?p=preview
But when I try to run that same work on my computer my test case are fail I am getting error this
Module 'app.home' 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.
Here is my computer code. https://dl.dropbox.com/s/no901z41bza7osm/SimpleDemo.zip?dl=0
Please run npm install to add dependency .
Here is my karma.conf.js file
// Karma configuration // Generated on Fri Dec 18 2015 19:53:32 GMT+0530 (IST) module.exports = function(config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '', // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['jasmine'], // list of files / patterns to load in the browser files: [ 'bower_components/angular/angular.js' , 'bower_components/jquery/dist/jquery.js' , 'bower_components/angular-ui-router/release/angular-ui-router.js' , 'bower_components/angular-mocks/angular-mocks.js' , 'bower_components/angular-resource/angular-resource.js' , 'app/*.js', 'app/**/*.js', 'app/**/*.html', 'test/**.js' ], // list of files to exclude exclude: [ ], // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { 'app/**/*.html':['ng-html2js'] }, ngHtml2JsPreprocessor:{ moduleName:'templates' }, // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ['progress'], // web server port port: 9876, // enable / disable colors in the output (reporters and logs) colors: true, // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel: config.LOG_INFO, // enable / disable watching file and executing tests whenever any file changes autoWatch: true, // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: ['Chrome'], // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: false, // Concurrency level // how many browser should be started simultanous concurrency: Infinity }) }
here is my code testing
(function(){ 'use strict' describe('http controller test', function() { var $rootScope, $scope, controller, $q, $httpBackend; beforeEach(function() { module('app'); inject(function($injector) { $rootScope = $injector.get('$rootScope'); $scope = $rootScope.$new(); controller = $injector.get('$controller')('homeCntrl', { $scope: $scope }) }) }) describe('Init value', function() { it('check name value', function() { expect(controller.message).toBeUndefined(); }) }) it('it should be true', function() { expect(true).toBeTruthy(); }) }) })()
any update ?how to do testing of controller?
update 1
when I write like that it is not working ...check these file
'app/**/*.js', 'app/*.js', 'app/home/controller/*.js', 'app/**/*.html', 'test/**.js'
whole code
files: [ 'bower_components/angular/angular.js' , 'bower_components/jquery/dist/jquery.js' , 'bower_components/angular-ui-router/release/angular-ui-router.js' , 'bower_components/angular-mocks/angular-mocks.js' , 'bower_components/angular-resource/angular-resource.js' , 'app/**/*.js', 'app/*.js', 'app/home/controller/*.js', 'app/**/*.html', 'test/**.js' ],
but when I write like that it work perfectly why ?
files: [ 'bower_components/angular/angular.js' , 'bower_components/jquery/dist/jquery.js' , 'bower_components/angular-ui-router/release/angular-ui-router.js' , 'bower_components/angular-mocks/angular-mocks.js' , 'bower_components/angular-resource/angular-resource.js' , 'app/home/*.js', 'app/app.js', 'app/home/controller/*.js', 'app/**/*.html', 'test/**.js' ],
解决方案Change
homeCntrl
tohomecntrl
In your route.js in this line:
controller:'homeCntrl as home'
这篇关于如何删除模块找不到错误的角度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!