angular - Angular2 - how to trigger an event from the app component to a route -


i new angular2 (haven't had experience angular1) , working on small website. need pretty straight forward. in template of appcomponent, there 2 buttons language selections. have route, let's /products, display list of products retrieved ws (http via service). when press 1 of language buttons, need products list refreshed. make http.get request in productsservice class, , subscribe observable in productscomponent class. how trigger request appcomponent, while still receiving subscription in productscomponent?

any appreciated

based on description, 2 things.

  • add productcomponent viewchild in appcomponent

    import {viewchild} '@angular/core'; export class appcomponent{     @viewchild(productcomponent) productcomponent;     public reloadproduct(): void {         this.productcomponent.reloadproduct();     } } 
  • store product information in productservice class in variable. when press language button, call web service , new product , store in productservice class variable. angular automatically change detection in productcomponent , display updated product list.


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -