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


TypeScript Router.subscribe方法代码示例

本文整理汇总了TypeScript中angular2/router.Router.subscribe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Router.subscribe方法的具体用法?TypeScript Router.subscribe怎么用?TypeScript Router.subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2/router.Router的用法示例。


在下文中一共展示了Router.subscribe方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

    constructor(private router: Router, private store: AppStore) {
        // Whenever the Angular route has an event, dispatch an event with the new
        // route data.
        router.subscribe(value => {
            // Don't show the side nav on the Sign In screen
            this.hideNav = value.indexOf("sign-in") !== -1;
            store.dispatch(routeChange(value));
            // Clear the package search when the route changes
            store.dispatch(setPackagesSearchQuery(""));
        });

        // Listen for changes on the state.
        store.subscribe(state => {
            // If the state has a requestedRoute attribute, use the router to navigate
            // to the route that was requested.
            const requestedRoute = state.router.requestedRoute;
            if (requestedRoute) { router.navigate(requestedRoute); }
        });

        this.removeNotification = function(i) {
            this.store.dispatch(removeNotification(i));
            return false;
        }.bind(this);

        this.signOut = function() {
            this.store.dispatch(signOut());
            return false;
        }.bind(this);

        this.toggleUserNavMenu = function() {
            this.store.dispatch(toggleUserNavMenu());
            return false;
        }.bind(this);

    }
开发者ID:OneOaaS,项目名称:habitat,代码行数:35,代码来源:AppComponent.ts

示例2: ngOnInit

    ngOnInit(): void {
        console.log(">>>> App OnInit");    

        this._router.subscribe((path) => {
            console.log(">>>> Route Change: " + path); 
        });
    }
开发者ID:a2dude,项目名称:route1,代码行数:7,代码来源:app.ts

示例3: applyBackWorkaround

 // https://github.com/angular/angular/issues/7722
 // https://github.com/angular/angular/issues/7873
 private applyBackWorkaround() {
     this._router.subscribe(() => {
         setTimeout(() => {
             this._applicationRef.tick();
         });
     });
 }
开发者ID:artiso-solutions,项目名称:vokabelchef-web,代码行数:9,代码来源:nativeIntegrationService.ts

示例4: constructor

 constructor(router:Router) {
   this.name = 'Alice';
   router.subscribe((url) => console.log('Navigated'));
   router.config( { 'path': '/home', 'component': Home  } )
   .then((_) => console.log("Home Registered"), err => console.log(err));
         //.then(() => router.navigate('/home'), err => console.log(err));
 }
开发者ID:lehmamic,项目名称:Angular2-Test,代码行数:7,代码来源:app.ts

示例5: constructor

 constructor (public guestService: GuestService, private _router: Router, private _location: Location) {
     // Hack to scroll top top on navigate.
     // (autoscroll not yet implemented in ng2)
     _router.subscribe(() => {
         window.scrollTo(0, 0);
     });
 }
开发者ID:vigie,项目名称:wedding-webapp,代码行数:7,代码来源:app.component.ts

示例6: constructor

 constructor(public router: Router) {
   // subscribe to router url updates
   router.subscribe((url) => {
     // convert the current url into an instruction
     this._getInstruction(url);
   });
 }
开发者ID:179309463,项目名称:AdminLTE-angular2,代码行数:7,代码来源:RouterState.ts

示例7: constructor

	constructor(private _router: Router, private _authService: AuthService) {
		this._router.subscribe(path => {
			if (!this._authService.isAuthorised()) {
				this._router.navigate(['/Landing']);
			}
	    });
	}
开发者ID:kamleshKumarVerma,项目名称:Job-Tracker-Angular-2-,代码行数:7,代码来源:app.component.ts

示例8: constructor

	constructor(private _router: Router, private _title: Title) 
	{
		this._router.subscribe((url) => 
		{ //Fires on every URL change
			this._title.setTitle(this.getCurrentTitle());
		});
	}
开发者ID:SlothHub,项目名称:Annotations,代码行数:7,代码来源:app.component.ts

示例9: constructor

 constructor(private _router: Router){
     
     // listening for route change and changing application title based on the url.
     this._router.subscribe((url: string)=>{
         this.title = url.startsWith('project') ? 'Projects' : 'Dashboard';
     });
 }
开发者ID:ramirescm,项目名称:angular2-tutorial-app,代码行数:7,代码来源:app.component.ts

示例10: constructor

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


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