当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Router.subscribe方法代码示例

本文整理汇总了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()}
            )
    }
开发者ID:jamezp,项目名称:jirban-jira,代码行数:30,代码来源:app.ts

示例2: constructor

 constructor(private router:Router,
             private location:Location,
             private loginService:LoginService) {
   this.isSignedIn = loginService.isSignedIn();
   router.subscribe(() => {
     this.isSignedIn = loginService.isSignedIn();
   });
 }
开发者ID:mauricio1990silva,项目名称:angular2-app,代码行数:8,代码来源:Header.ts

示例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();
   });
 });
开发者ID:cipengxu,项目名称:angular2-app,代码行数:8,代码来源:login.component.spec.ts

示例4: constructor

 constructor(private slimLoader: SlimLoadingBarService, private router: Router) {
     this.runSlimLoader();
     this.router.subscribe((value: any) => {
         this.runSlimLoader();
     }, (error: any) => {
         this.slimLoader.complete();
     });
 }
开发者ID:XK8,项目名称:ng2-webpack-demo,代码行数:8,代码来源:app.component.ts

示例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;
 }
开发者ID:mrvelibor,项目名称:IksOks,代码行数:10,代码来源:app.component.ts

示例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();
   });
 });
开发者ID:cipengxu,项目名称:angular2-app,代码行数:10,代码来源:header.component.spec.ts

示例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;
     })
 }
开发者ID:pracxs,项目名称:angular-2-sofia,代码行数:11,代码来源:contacts-list.component.ts

示例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;
     })
 }
开发者ID:georgema1982,项目名称:angular-2-intro,代码行数:13,代码来源:contacts-list.component.ts


注:本文中的@angular/router-deprecated.Router.subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。