當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。