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
Post a Comment