这里假设我有10个页面,但我想限制一些用户在10个页面中只能访问3到4页。如何使用angularjs 2实现这一点。请帮我一个静态数据的示例应用程序。谢谢..
答案 0 :(得分:1)
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'product-details',
template: `
<div>
Showing product details for product: {{id}}
</div>
`,
})
export class LoanDetailsPage implements OnInit, OnDestroy {
id: number;
private sub: any;
constructor(private route: ActivatedRoute, private __userType: UserTypeService) {}
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
console.log(params); // you will get which router is being redirected
if(__userType.type.hasAllowed){
// service to get is user allowed to redirected..
}
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
}