angularjs - Angular 2.0 Routing Issue -
in main.ts code this.
import {provide, enableprodmode} 'angular2/core'; import {bootstrap} 'angular2/platform/browser'; import {router_providers} 'angular2/router'; import {http_providers} 'angular2/http'; import {app_base_href} 'angular2/platform/common'; import {appcomponent} './app/components/app.component'; enableprodmode(); bootstrap(appcomponent, [ router_providers, http_providers, provide(app_base_href, { usevalue: '<%= app_base %>' }) ]);
in app.component.ts file have follwing code.
import {component} 'angular2/core'; import {enableprodmode} 'angular2/core'; import {router, router_directives, router_providers, routeconfig, routeparams} 'angular2/router'; import {sportslivefeedservice} '../shared/index'; import {maincomponent} '../main/index'; import {resultscomponent} '../results/index'; @component({ selector: 'sd-app', viewproviders: [sportslivefeedservice], templateurl: 'app/components/app.component.html', styleurls: ['css/bootstrap.min.css', 'css/main.css'], directives: [router_directives] }) @routeconfig([ { path: '/', name: 'main', component: maincomponent }, { path: '/results/:id', name: 'results', component: resultscomponent } ]) export class appcomponent { constructor(private router: router) {} }
and in resultscomponent code this.
import {component} 'angular2/core'; import {inject} 'angular2/di'; import {core_directives, form_directives} 'angular2/common'; import {sportslivefeedservice} '../../shared/index'; @component({ selector: 'sd-about', templateurl: 'app/results/components/results.component.html', styleurls: ['css/bootstrap.min.css', 'css/main.css'], directives: [form_directives, core_directives], providers: [sportslivefeedservice] }) export class resultscomponent implements oninit { eventsdetails: []; constructor(private _sportslivefeedservice: sportslivefeedservice){ this._sportslivefeedservice = _sportslivefeedservice; } ngoninit(){ this._sportslivefeedservice .geteacheventindetailbymeetingid() .subscribe(p => this.eventsdetails = p) } }
the issue when first screen loading fine. when navigate http://localhost:5555/results/121212 this, second screen ui not showing. please me fix issue. new angular 2.0
Comments
Post a Comment