Hi Sander,
I have changed reroute to fit my requirement but not sure why whole page is
loading
I was trying to take external file attribute and compare with deferred list if
attribute is there then load the page within component as it happens in angular.
ngOnInit() {
this._Faqservice.getFaqList();
}
reroute(me) {
// use the closure to keep a reference to me(this)
return function reroute(ev) {
// might be confusing, but 'this' points to the element
// orignating the click.
ev.preventDefault();
const routeattr = this.getAttribute('routeattr');
let routeid = this._Faqservice.getFaqList.id;
if (routeattr === routeid){
console.log("exists");
let routepageid = this._Faqservice.getFaqList.pageId
console.log(routepageid);
}
me.router.navigate(['/answer'], {relativeTo: me.activeRouter}, {
skipLocationChange: true,
});
}
route module file
const appRoutes: Routes = [
{ path: '', redirectTo: 'faqlist', pathMatch: 'full' },
{ path: 'faqlist', component: FaqlistComponent},
{ path: 'answer/:id', component: AnswerComponent }
];
service with method for deferred list
getFaqId(id: any) {
return this.getFaqList().then((obj) => obj.find(faqlist => faqlist.id ===
id));
}
getFaqList(){
var def = $.Deferred();
setTimeout(function(){
var obj = [
{id:'news', pageid:'1234'},
{id:'2', pageid:'4567' },
{id:'3', pageid:'97646709877' }
]
def.resolve(obj);
}, 100)
return def;
}
Thanks for your help, i can post the code on plunker if you want.
Regards
Shweta
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.