Project

General

Profile

« Previous | Next » 

Revision 56395

[Connect|Trunk]: Use RoutesRecognized event to read query params.

View differences:

app.component.ts
1 1
import {Component} from '@angular/core';
2
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
2
import {ActivatedRoute, NavigationStart, Router, RoutesRecognized} from '@angular/router';
3 3

  
4 4
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
5 5
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
......
64 64
   constructor(  private  route: ActivatedRoute, private propertiesService:EnvironmentSpecificService,
65 65
                 private _communitiesService:CommunitiesService, private _subscribeService: SubscribeService,
66 66
                 private router: Router){//, private _layoutService: LayoutService) {
67
     router.events.forEach((event) => {
68
       if (event instanceof NavigationStart) {
69
         HelperFunctions.scroll();
70
       }
71
     });
72 67
   }
73 68

  
74 69
   ngOnInit() {
......
77 72
                 this.properties = this.propertiesService.envSpecific;
78 73
                 var communityId: string = "";
79 74
                 this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI);
80
                 if(this.properties.environment == "development") {
81
                   this.route.queryParams.subscribe(data => {
82
                     this.showMenu = false;
83
                     communityId = data['communityId'];
84
                     this.buildMenu(communityId);
85
                   });
86
                 } else {
87
                   this.showMenu = false;
88
                   communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
89
                   this.buildMenu(communityId);
90
                 }
75
                 this.router.events.forEach((event) => {
76
                   if (event instanceof RoutesRecognized) {
77
                     HelperFunctions.scroll();
78
                     if (this.properties.environment == "development") {
79
                         this.showMenu = false;
80
                         communityId = (event.state.root.firstChild.queryParams['communityId']) ? event.state.root.firstChild.queryParams['communityId'] : '';
81
                         console.log(communityId);
82
                         this.buildMenu(communityId);
83
                     } else {
84
                       this.showMenu = false;
85
                       communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
86
                       this.buildMenu(communityId);
87
                     }
88
                   }
89
                 });
91 90

  
92 91
     if (typeof document !== 'undefined') {
93 92
       try{

Also available in: Unified diff