【发布时间】:2019-07-23 05:47:56
【问题描述】:
我有这个 Angular 7 应用程序,它运行良好,直到我决定将我的逻辑从 app.component.ts 文件移到一个新的 login.component.ts 文件中。自从我这样做以来,当我尝试登录并且应用程序查询数据库时,它使用了错误的 url--4200 而不是 3000。我设置了一个这样的 proxy.conf.json 文件:
{
"/api": {
"target": "http://localhost:3000",
"secure": false
}
}
这实际上在我切换出我的 app.component.ts 文件之前就已经设置好了。除了重新连接从移动到另一个组件的所有内容之外,我没有进行任何其他更改。我找不到 Angular 指向 localhost:4200 而不是 3000 的位置。有人有什么想法吗?提前致谢。把我的头撞在墙上。我的操作系统是运行 VS Code 的 Windows 10。
这是我下期的错误:
VM623:37 ERROR TypeError: Cannot read property '0' of undefined
at
LoginComponent.push../src/app/login/login.component.ts.LoginComponent.toPrint
以下是与此错误有关的两个函数:
toPrint(match) {
return `Name: ${this.match[0].name} Checking: ${this.match[0].checking}
Savings: ${this.match[0].savings}`
}
printUserData(match){
this.buttonPressed = true;
return this.loginComponent.toPrint(match);
}
【问题讨论】:
-
嗨,比尔,您是否将代理配置放在 angular.json 文件中...??
-
它仍在发生。我很困惑是什么原因造成的。我以为我重新配置了 proxy.conf.json 文件,但它不起作用。我希望其他人有一些想法。
-
bill,你能分享你的 angular.json 文件吗
-
文件太大,无法共享 Samarth。你想知道什么?我那里没有任何配置选项。正如我上面所说,它们在 proxy.conf.json 文件中。
-
好的,只需在 angular.json 文件中分享服务部分的代码
标签: node.js angular mongodb mongoose angular7