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

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -