• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Seegatesite Header

Seegatesite.com

Seegatesite.com - Programming Tutorial , Sharing , How and Learn Together

  • TOOLS
    • My Tools
    • Bootstrap Navbar Online Generator
    • Bootstrap Demo
    • Amazon Asin Grabber
    • Azoncast v2 Theme
  • ADVERTISE
  • CATEGORIES
    • Android
    • Blogging Tips
    • Database
    • CSS
    • Info Gadget
    • Javascript
    • Linux
    • PHP
    • Various
    • WordPress
  • PHP
  • JAVASCRIPT
  • JQUERY
  • ANGULAR
  • WORDPRESS
  • SEO
🏠 » Javascript » Tutorial Angular 4 Reload Init On Parameter Change In The Same Route

Tutorial Angular 4 Reload Init On Parameter Change In The Same Route

By Sigit Prasetya Nugroho ∙ November 24, 2017 ∙ Javascript ∙ Leave a Comment

Angular Tutorial 4 trick how to reload init value when parameter change occurs on the same route. This time I experienced problems with angular 4 when changing parameters on the same route, init data did not change. This problem happens because the Angular does not refresh the page on the same route.

The solution is quite easy, recall the init function when we capture the parameters thrown by the route with the following script.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
contructor(
private route: ActivatedRoute){
this.sub = route.queryParams.subscribe(params => {
      this.param1 = params['param1'];
      this.param2 = params['param2'];
      this.initialstate();
});
}
initialstate(){
//your init value here
}
 
  ngOnInit() {
// another code
// another code
// another code
// another code
    this.initialstate();
  }

The above script I got directly from the site https://stackoverflow.com/a/42835928, thanks to gpanagopoulos who have shared.

I created this article in addition to sharing how to complete the reload component on the same router as a reminder for my angular project later on.

Read another article: How to Create Autofocus Directive Certain Elements Angular 4

So this brief article may be useful

Avatar for Sigit Prasetya Nugroho

About Sigit Prasetya Nugroho

This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Do you want to get Free WordPress Videos, Plugins, and Other Useful Resources ?

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

we respect your privacy and take protecting it seriously

Popular Articles

How To Replace String With Another String In PHP

September 16, 2019 By Sigit Prasetya Nugroho Leave a Comment

Increase Traffic with the Right Yoast Settings

October 16, 2014 By Sigit Prasetya Nugroho Leave a Comment

Boost Social Media Traffic with OnePress Social Locker

October 17, 2014 By Sigit Prasetya Nugroho Leave a Comment

Amazon Custom Thumbnail Plugin New Version Launch

September 18, 2014 By Sigit Prasetya Nugroho Leave a Comment

Web Applications as Desktop Flavor with Ajax Agent

October 11, 2014 By Sigit Prasetya Nugroho Leave a Comment

Tags

adminlte adsense adsense tips affiliate amazon ajax amazon Android angular angular 4 angular 5 asin grabber Bootstrap codeigniter create wordpress theme crud css free wordpress theme google adsense imacros increase traffic jquery laravel laravel 5 learn android modal dialog mysql nodeJs optimize seo pdo php plugin pos Publisher Tips SEO theme tutorial tutorial angular tutorial angular 4 tutorial javascript tutorial javascript beginners twitter widget wordpress wordpress plugin XMLRPC




  • About
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

©2019 Seegatesite.com