Call a function in another function

70 views
Skip to first unread message

Zako

unread,
Feb 1, 2021, 5:01:17 AM2/1/21
to Angular and AngularJS discussion
Hi,  I am new here and new and angular. Could you help me please ?

I would like to use a function from another function but it doesn't work

In my function "updateData", I try to re-call my function "getInitData" but it don't work.
Have you got an idea please ?


ngOnInit() { 
     this.getInitData(); 
 } 

getInitData() { 
     this.route.params.subscribe((params: Params) => { this.model=this.userData; }); 
 }    

updateData() { 
     //code to update my data ... here it's ok
     this.getInitData(); 
 } 


Thanks a lot

bastien lemaire

unread,
Feb 1, 2021, 5:17:06 AM2/1/21
to ang...@googlegroups.com
this.route.params.subscribe
 This is used to listen to changes to the route params. Calling the function a second time will just create a new subscription meaning the data will now refresh twice instead of once when route.params changes.

you're not using the data sent by route.params, it seems you don't need it at all... what is this.userData, where does it come from?



Bastien Lemaire


--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/91350bfb-3723-4be6-ab28-aea392fdffccn%40googlegroups.com.

Zako

unread,
Feb 1, 2021, 5:43:04 AM2/1/21
to Angular and AngularJS discussion
Thanks for your reply,

this.userdata is a json object come from my serveur

So, I have a list of user, I would like to update the list after add/change/delete a user ... I try to use setInterval() but it's impossible to use this, there to many request is send to my serveur.

I would like a update my view after change ... how could I do this please ?

thanks a lot

Reply all
Reply to author
Forward
0 new messages