Angular 2 - Uncaught (in promise): Error: XHR error (404 Not Found) [英] Angular 2 - Uncaught (in promise): Error: XHR error (404 Not Found)

查看:35
本文介绍了Angular 2 - Uncaught (in promise): Error: XHR error (404 Not Found)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的英语很差,我为此道歉:)

my english is poor, my apology for this :)

我的 angular 2 有问题.我会创建一个登录表单,但在调用 Web 服务并得到响应后,我在下面遇到了这个错误.

I have a problem with angular 2. I would create a login form but after call web service and get response I had this error below.

为了在我的应用程序上阻止和授权用户,我基于 angular 教程的 auth-guard.service.ts.

To blocked and authorized user on my app I'm based on auth-guard.service.ts of angular tutorial.

此错误发生在我的路由上的 canLoad 操作之后.

This error come after the canLoad action on my routing.

我使用 angular 2 最新版本,我的项目基于 webpack.

I use angular 2 latest version, my project is based on webpack.

我的错误:

core.umd.js?e2a5:3004 EXCEPTION: Uncaught (in promise): Error: XHR error (404 Not Found) loading http://localhost:9090/app/home/home.module
    Error loading http://localhost:9090/app/home/home.module
Error: XHR error (404 Not Found) loading http://localhost:9090/app/home/home.module
    at o (https://code.angularjs.org/tools/system.js:4:12694)
    at XMLHttpRequest.I.s.onreadystatechange (https://code.angularjs.org/tools/system.js:4:13219)
    at XMLHttpRequest.wrapFn [as _onreadystatechange] (eval at <anonymous> (http://localhost:9090/polyfills.js:2195:2), <anonymous>:698:29)
    at ZoneDelegate.invokeTask (eval at <anonymous> (http://localhost:9090/polyfills.js:2195:2), <anonymous>:265:35)
    at Object.onInvokeTask (eval at <anonymous> (http://localhost:9090/vendor.js:100:2), <anonymous>:6197:41)
    at ZoneDelegate.invokeTask (eval at <anonymous> (http://localhost:9090/polyfills.js:2195:2), <anonymous>:264:40)
    at Zone.runTask (eval at <anonymous> (http://localhost:9090/polyfills.js:2195:2), <anonymous>:154:47)
    at XMLHttpRequest.ZoneTask.invoke (eval at <anonymous> (http://localhost:9090/polyfills.js:2195:2), <anonymous>:335:33)

如果您有任何解决方案:)

If you have any solutions :)

推荐答案

我已经解决了我的问题......

I Have solved my problem ...

在Webpack上下文中使用Router loadChidren:

In the context of Webpack to use Router loadChidren :

---> 你必须像这样在你的 webpack 配置中实现 'angular2-router-loader':

---> You must implements 'angular2-router-loader' in your webpack config like this :

loaders: [
      {
        test: /\.ts$/,
        loaders: ['awesome-typescript-loader', 'angular2-template-loader','angular2-router-loader']
      },
...
],

而且,要使用此路由器加载程序,您必须安装它:

And, to use this router loader you must install it :

npm install angular2-router-loader -- save-dev

我在这个网站上看到了解决方案:

I have see the solution on this website :

https://medium.com/@daviddentoom/angular-2-lazy-loading-with-webpack-d25fe71c29c1#.p5wy52jv1

并且,不能在父模块中导入子模块;)

And, must not import child module in parent module ;)

这篇关于Angular 2 - Uncaught (in promise): Error: XHR error (404 Not Found)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆