路由器链接点击后刷新组件 [英] Refresh component after router-link click

查看:111
本文介绍了路由器链接点击后刷新组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在各个组件之间共享列表组件,用于列出一些数据和绑定到ng-model的日期选择器。喜欢



< input type =textclass =form-control[(ngModel)] =dateRange
placeholder =选择日期范围bsDaterangepicker #dp =bsDaterangepicker
(bsValueChange)=onDateRangeChange($ event)/>





以下是访问这些列表组件的URL格式父组件 -



 http: //   localhost:4200 /#/ topics  



子组件



 http: //   localhost / topics / Recrug-4  



问题是当我点击父组件时,ng-model值会刷新但是当我登陆时在使用子组件的页面上,ngModel值未刷新



我尝试过:



单击路由器链接后。我调用了一个函数来更新列表组件上的ngmodel。为了测试,我甚至回忆起ngononit功能,但没有成功

解决方案

event)/>





以下是访问这些列表组件的URL格式父组件 -



 http: //   localhost:4200 /#/ topics  



子组件



 http: //   localhost / topics / Recrug-4  



问题是当我点击父组件时,ng-model值会刷新但是当我登陆时在使用子组件的页面上,ngModel值未刷新



我尝试过:



一旦点击路由器链接。我调用了一个函数来更新列表组件上的ngmodel。为了测试,我甚至召回了ngononit函数但没有成功ESS


I have list component shared between various components for listing some data and a datepicker binded to an ng-model. Like

<input type="text" class="form-control"  [(ngModel)]="dateRange" 
placeholder="Pick a date range" bsDaterangepicker #dp="bsDaterangepicker"
(bsValueChange)="onDateRangeChange($event)"/>



Below are the urls formats for accessing these list component Parent Component -

http://localhost:4200/#/topics


Child Component

http://localhost/topics/Recrug-4


The issue is when I click on the parent component , the ng-model values are refreshed but when I land on the pages using the Child Components , the ngModel values are not getting refreshed

What I have tried:

As soon as the router link is clicked. I called a function to update ngmodel on the list component. For testing , I even recalled ngononit function but no sucess

解决方案

event)"/>



Below are the urls formats for accessing these list component Parent Component -

http://localhost:4200/#/topics


Child Component

http://localhost/topics/Recrug-4


The issue is when I click on the parent component , the ng-model values are refreshed but when I land on the pages using the Child Components , the ngModel values are not getting refreshed

What I have tried:

As soon as the router link is clicked. I called a function to update ngmodel on the list component. For testing , I even recalled ngononit function but no sucess


这篇关于路由器链接点击后刷新组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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