简体   繁体   English

角模块注入错误

[英]Angular module injection error

I am trying to create a sample Angular app with .Net, just to get the idea how to connect two of them but I can not get rid of this injector::modulerr error. 我正在尝试使用.Net创建一个示例Angular应用程序,只是为了了解如何连接两个应用程序的想法,但我无法摆脱这个jector :: modulerr错误。 Tried variety of things, changing dependencies, removing empty brackets and so on but nothing changes. 尝试了各种各样的事情,更改了依存关系,删除了方括号等,但没有任何变化。 I have created plunker to keep this thread cleaner the link is below. 我创建了插件,以保持此线程更清洁,下面是链接。

http://plnkr.co/edit/5AHsUSrFib4dkiX6XjLY?p=preview http://plnkr.co/edit/5AHsUSrFib4dkiX6XjLY?p=preview

I think the error keeps coming from this one 我认为错误总是来自这个

 angular.module('angularTest', ['ngRoute']).config(['$routeProvider', '$routeParams', '$httpProvider', function ($routeProvider, $routeParams, $httpProvider) { console.log('1'); $routeProvider. when('/routeOne', { templateUrl: 'routesDemo/one' }) .when('/routeTwo/:donuts', { templateUrl: function (params) { return '/routesDemo/two?donuts=' + params.donuts } }) .when('/routeThree', { templateUrl: 'routesDemo/three' }) .when('/login?returnUrl', { templateUrl: '/Account/Login', controller: LoginController }); console.log('2'); $httpProvider.interceptors.push('AuthHttpResponseInterceptor'); } ]); 

Thanks for your time. 谢谢你的时间。

$routeParams should be post fix with Provider as you can only use provider in config phase. $routeParams应该与Provider一起修复,因为您只能在配置阶段使用Provider。

Also you should always define app only once then append it by using that module, recreating angular.module will flush the old app & new copy will treated as that module. 同样,您应该只定义一次应用程序,然后使用该模块附加它,重新创建angular.module将刷新旧应用程序,而新副本将被视为该模块。 In you service & controller you need to make change from angular.module('angularTest',[]) to angular.module('angularTest') 在服务和控制器中,您需要从angular.module('angularTest',[])更改为angular.module('angularTest')

Additionally you missed to add ' on LogInController 另外,您错过了在LogInController上添加'

  .when('/login?returnUrl', {
     templateUrl: '/Account/Login',
     controller: 'LoginController' //<--here added qoutes
  });

One last thing, you missed to add AuthHttpResponseInterceptor.js which was not recognize by the angular app and was throwing AuthHttpResponseInterceptor factory not defined. 最后一件事,您错过了添加AuthHttpResponseInterceptor.js应用程序无法识别的AuthHttpResponseInterceptor.js ,并抛出了AuthHttpResponseInterceptor工厂。

Working Plunkr 工作朋克

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM