angular - angular2 - dynamic url for component(like: /heroes or /heroes/:id all for HeroComponent) -


@routeconfig([   {path: '/heroes(/:id)?', name: 'heroes', component: herocomponent} ])  ngoninit() {   let id = this._routeparams.get('id');   if (id) {     this._service.findbyid(id).then(hero => this.hero = hero);   } else {     this._service.findby(null).then(heroes => this.heroes = heroes)   } } 

when has id,findbyid(id) other findby(model),because list view , detail view in 1 page,and want write code in 1 .ts file, how resolve?

@routeconfig([   {path: '/heroes', name: 'heroes', component: herocomponent} ]) 

get url /heroes?id=11,not rest,and config 2 route badly


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -