且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Angular 2.0,如何检测子组件上的路线更改

更新时间:2023-02-26 14:18:56

创建一个预订router的全局服务,并将该服务注入到您想知道的有关路由更改的任何位置.该服务可以通过Observable本身公开更改,因此感兴趣的组件也可以订阅以自动获得通知.

Create a global service that subscribes to router and inject the service wherever you want to know about route changes. The service can expose changes by an Observable itself so interested components also can subscribe to get notified automatically.