本文整理汇总了TypeScript中@angular/router-deprecated.Router.subscribe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Router.subscribe方法的具体用法?TypeScript Router.subscribe怎么用?TypeScript Router.subscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/router-deprecated.Router
的用法示例。
在下文中一共展示了Router.subscribe方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(router:Router, progressError:ProgressErrorService, versionCheckService:VersionCheckService) {
this._router = router;
this._progressError = progressError;
this.loginUrl = RestUrlUtil.caclulateRestUrl("login.jsp");
router.subscribe((route:string) => {
//Hack to hide the body scroll bars on the board page.
//This is only really necessary on FireFox on linux, where the board's table
//seems have extra width added to allow for the scrollbars on the board's divs
let showBodyScrollbars:boolean = true;
if (route.startsWith("board?board")) {
showBodyScrollbars = false;
}
document.getElementsByTagName("body")[0].className = showBodyScrollbars ? "" : "no-scrollbars";
});
this._progressError.startProgress(true);
versionCheckService.getVersion()
.subscribe(
data => {
let version:number = data.version;
if (version != VERSION) {
this._progressError.setErrorString("You appear to be using an outdated/cached version of the client. " +
"Please empty your browser caches and reload this page.")
}
},
error => {this._progressError.setError(error)},
() => {this._progressError.finishProgress()}
)
}
示例2: constructor
constructor(private router:Router,
private location:Location,
private loginService:LoginService) {
this.isSignedIn = loginService.isSignedIn();
router.subscribe(() => {
this.isSignedIn = loginService.isSignedIn();
});
}
示例3: it
it('can navigate to signup page', (done) => {
const el = cmpDebugElement.nativeElement;
getDOM().querySelector(el, 'a').click();
router.subscribe(() => {
expect(location.path()).toEqual('/signup');
done();
});
});
示例4: constructor
constructor(private slimLoader: SlimLoadingBarService, private router: Router) {
this.runSlimLoader();
this.router.subscribe((value: any) => {
this.runSlimLoader();
}, (error: any) => {
this.slimLoader.complete();
});
}
示例5: constructor
constructor(private router: Router, private http: Http) {
this.onPage = true;
router.subscribe((val) => {
this.token = localStorage.getItem('token');
this.username = localStorage.getItem('username');
this.isAuth = this.token != null;
});
this.activeGames = -1;
this.loggingOut = false;
}
示例6: it
it('shows a nav link to sign in', (done) => {
const link = getDOM().querySelector(cmpDebugElement.nativeElement, '#navbar li.login>a');
expect(link).toBeTruthy();
link.click();
router.subscribe(() => {
fixture.detectChanges();
expect(location.path()).toEqual('/login');
done();
});
});
示例7: ngOnInit
ngOnInit() {
this.persons = this._personService.getAll();
this._router.subscribe(id => {
if( id!=='' && +id > 0)
if(!this.selected || this.selected.id != id)
this.selected = this._personService.getById(+id)
else
this.selected = null;
})
}
示例8: ngOnInit
ngOnInit() {
this.persons = this._personService.getAll();
this._router.subscribe(state => {
let id = +state.instruction.params.id
if( id > 0)
if(!this.selected || this.selected.id != id)
this.selected = this._personService.getById(id)
else
this.selected = null;
})
}