mirror of
				https://github.com/richard-loafle/fuse-angular.git
				synced 2025-11-04 00:53:34 +00:00 
			
		
		
		
	(Contacts App) Fixed: Selected filter is not preserved on route changes
This commit is contained in:
		
							parent
							
								
									5f2372cc08
								
							
						
					
					
						commit
						751497556a
					
				@ -1,31 +1,35 @@
 | 
			
		||||
import { Component, OnInit } from '@angular/core';
 | 
			
		||||
import { Component, OnDestroy } from '@angular/core';
 | 
			
		||||
import { ContactsService } from '../../contacts.service';
 | 
			
		||||
import { Subscription } from 'rxjs/Subscription';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
    selector   : 'fuse-contacts-main-sidenav',
 | 
			
		||||
    templateUrl: './main.component.html',
 | 
			
		||||
    styleUrls  : ['./main.component.scss']
 | 
			
		||||
})
 | 
			
		||||
export class FuseContactsMainSidenavComponent implements OnInit
 | 
			
		||||
export class FuseContactsMainSidenavComponent implements OnDestroy
 | 
			
		||||
{
 | 
			
		||||
    user: any;
 | 
			
		||||
    filterBy: string;
 | 
			
		||||
    onUserDataChangedSubscription: Subscription;
 | 
			
		||||
 | 
			
		||||
    constructor(private contactsService: ContactsService)
 | 
			
		||||
    {
 | 
			
		||||
        this.filterBy = 'all';
 | 
			
		||||
        this.filterBy = this.contactsService.filterBy || 'all';
 | 
			
		||||
        this.onUserDataChangedSubscription =
 | 
			
		||||
            this.contactsService.onUserDataChanged.subscribe(user => {
 | 
			
		||||
                this.user = user;
 | 
			
		||||
            });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ngOnInit()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    changeFilter(filter)
 | 
			
		||||
    {
 | 
			
		||||
        this.filterBy = filter;
 | 
			
		||||
        this.contactsService.onFilterChanged.next(this.filterBy);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ngOnDestroy()
 | 
			
		||||
    {
 | 
			
		||||
        this.onUserDataChangedSubscription.unsubscribe();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user