private handleError(error: any) {
     let errorMessage: any;
     if (error instanceof HttpErrorResponse) {
         if (error.status === 401 || error.status === 403) {
             this.router.navigateByUrl('');
             this.sms.displayErrorMessage('You are not authenticated to access that page');
         }
         errorMessage = error.error || JSON.stringify(error);
         if (errorMessage.error) {
             errorMessage = errorMessage.error;
         }
         errorMessage = `${error.status} - ${error.statusText || ''}: ${errorMessage}`;
     } else {
         errorMessage = error.message ? error.message : error.toString();
     }
     return throwError(errorMessage);
 }
 goTo(url: string) {
   if (this.order.billing.name &&
       this.order.billing.email &&
       this.order.billing.address &&
       this.order.billing.city &&
       this.order.billing.state &&
       this.order.billing.zip) {
         this.globalService.order.next(this.order);
         this.router.navigateByUrl(url);
         this.localCart.orderUpdateItems(this.order);
     } else {
         let snackBarRef = this.snackBar.open('You must complete the form', 'OK!', {
           duration: 3000,
           extraClasses: ['warn-snackbar']
         });
     }
 }
	// ---
	// PUBLIC METHODS.
	// ---

	// I navigate to the first item in the filtered list.
	public handleEnter() : void {

		var project = this.filteredProjects.find(
			( filteredProject: FilteredProject ) : boolean => {

				return( filteredProject.isVisible );

			}
		);

		if ( project ) {

			this.router.navigateByUrl( project.resource );

		}

	}
	// ---
	// PUBLIC METHODS.
	// ---

	// I determine if the requested route can be activated (ie, navigated to).
	public canActivate(
		activatedRouteSnapshot: ActivatedRouteSnapshot,
		routerStateSnapshot: RouterStateSnapshot
		) : boolean {

		// We don't want this modal to show on page-refresh. As such, if this is a page-
		// refresh, we'll navigate to the same URL less the modal outlet.
		if ( this.isPageRefresh() ) {

			this.router.navigateByUrl( this.getUrlWithoutModal( routerStateSnapshot ) );
			return( false );

		}

		return( true );

	}
 constructor(
   public snackBar: MdSnackBar,
   public router: Router,
   public globalService: GlobalService,
   public localCart: LocalCartService,
   private title: Title,
   private meta: Meta
 ) {
   this.states = globalService.states;
   this.order = globalService.order.getValue();
   if (!this.order.shipping) {
     router.navigateByUrl('cart');
   }
   if (this.localCart.orderHasItems() && this.localCart.orderHas('billing')) {
     this.order = this.localCart.orderGetItems();
   }
 }
      data => {
        if (data['error']) {
          this.loading = false;

          this.message = {
            type: 'danger',
            message: data['message']
          };
        }else {
          let user = Object.assign(new User(), data['user']);
          user.token = data['token'];
          user.role = user.role.id;
          user.isLogged = true;
          this.store.dispatch({type: SET_VALIDATE_TOKEN, payload: true});
          this.store.dispatch({type: SET_USER, payload: user});
          this.router.navigateByUrl('dashboard/subscriber_project/general');
        }
      }, err => {
    _router.events.subscribe( e=>{


      console.log( e );
      if( e instanceof NavigationStart ){
        console.log("starting navigation.");
      }

      if( e instanceof NavigationEnd ) {
        console.log("ending navigation.");
      }

      if( e instanceof NavigationError ) {

        let lowerCaseUrl = e.url.toLowerCase();
        this._router.navigateByUrl( lowerCaseUrl);
      }
    })
 }, (err: any) => {
   if (err instanceof HttpErrorResponse) {
     if (err.status === 401) {
       // TODO: Add information about unAuthorized to user and redirect user.
       console.log('We intercepted a 401 boys!!!');
     }
     if (err.status === 404) {
       console.log(err.url);
       console.log('We intercepted a 404 boys!!!');
       const role = localStorage.getItem('Role');
       console.log(role);
       if (role === 'Group' && err.url.includes('contracts')) {
         console.log('Redirecting to newContract');
         this.router.navigateByUrl('contracts/newContract');
       }
     }
   }
 });
 .then((_) => {
   ObservableWrapper.subscribe<string>(eventBus, (ev) => {
     if (ev.startsWith('deactivate')) {
       completer.resolve(true);
       fixture.detectChanges();
       expect(fixture.debugElement.nativeElement).toHaveText('parent {deactivate cmp}');
     }
   });
   rtr.navigateByUrl('/a').then((_) => {
     fixture.detectChanges();
     expect(fixture.debugElement.nativeElement).toHaveText('A');
     expect(log).toEqual([
       'deactivate: /child-deactivate -> null',
       'parent deactivate: /parent-deactivate -> /a'
     ]);
     async.done();
   });
 });
	// ---
	// PUBLIC METHODS.
	// ---

	// I determine if the requested route can be activated (ie, navigated to).
	public canActivate(
		activatedRouteSnapshot: ActivatedRouteSnapshot,
		routerStateSnapshot: RouterStateSnapshot
		) : boolean {

		// We don't want to render this secondary view on page-refresh. As such, if this
		// is a page-refresh, we'll navigate to the same URL less the secondary outlet.
		if ( this.isPageRefresh() ) {

			console.warn( "Secondary view not allowed on refresh." );
			this.router.navigateByUrl( this.getUrlWithoutSecondary( routerStateSnapshot ) );
			return( false );

		}

		return( true );

	}