Angular ngoninit在路由时每次都被调用

发布于 2025-01-28 10:17:17 字数 229 浏览 1 评论 0原文

我有一个组件详细信息,其中其他儿童组件的路线在其中。发生的事情是,当我路由到任何其他子女组件时,详细信息就会被调用。

例如 - example.com/details/123123123/profile是我当前的路线,

我正在导航到example.com/details/12312331/pastappoartment

,那么详细信息的ngoninit就被调用了。这打电话给我不想要的所有API。

I have one component Details where the routes for other child components is there. What is happening is that when I route to any other child component then the onint of the Details is getting called.

For Example- example.com/details/123123123/profile is my current route

I am navigating to example.com/details/12312331/pastappointment

then the NgOnInit of Details is getting called. Which is calling all the apis that I don't want.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瀞厅☆埖开 2025-02-04 10:17:17

您必须

<router-outlet></router-outlet> 

在详细信息组件中使用。

You have to use

<router-outlet></router-outlet> 

inside your Details component.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文