import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { Component, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Store } from '@ngrx/store'; import { QueryParams } from '../types/params.type'; @Component({ selector: 'app-pages-organization-index', templateUrl: './index.page.component.html', styleUrls: ['./index.page.component.scss'] }) export class IndexPageComponent implements OnInit, OnDestroy { // tslint:disable-next-line: variable-name _searchData: { companyCode: string; searchWord: string; isSearch: boolean; }; deptSeq: string; private ngOnDestroySubject: Subject; constructor( private store: Store, private activatedRoute: ActivatedRoute, private changeDetectorRef: ChangeDetectorRef ) {} ngOnInit(): void { this.ngOnDestroySubject = new Subject(); this.activatedRoute.queryParams .pipe(takeUntil(this.ngOnDestroySubject)) .subscribe((params) => { console.log('activatedRoute.queryParams'); if (!!params) { const companyCode = params[QueryParams.DEPT_SEQ]; console.log('activatedRoute.queryParams', companyCode); this._searchData = { companyCode, searchWord: '', isSearch: false }; } }); } ngOnDestroy(): void { if (!!this.ngOnDestroySubject) { this.ngOnDestroySubject.complete(); } } }