fuse-angular/src/app/main/content/pages/faq/faq.component.ts
Sercan Yemen 397c304ab2 Created modules for custom components and the main fuse components
+ Changed the Shared Module (WIP)
2018-02-21 09:36:41 +03:00

66 lines
1.4 KiB
TypeScript

import { Component, OnInit, OnDestroy } from '@angular/core';
import { FormControl } from '@angular/forms';
import { Subscription } from 'rxjs/Subscription';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import { FuseUtils } from '@fuse/utils';
import { FaqService } from './faq.service';
@Component({
selector : 'fuse-faq',
templateUrl: './faq.component.html',
styleUrls : ['./faq.component.scss']
})
export class FuseFaqComponent implements OnInit, OnDestroy
{
faqs: any;
faqsFiltered: any;
step = 0;
searchInput;
onFaqsChanged: Subscription;
constructor(private faqService: FaqService)
{
this.searchInput = new FormControl('');
}
ngOnInit()
{
this.onFaqsChanged =
this.faqService.onFaqsChanged
.subscribe(response => {
this.faqs = response;
this.faqsFiltered = response;
});
this.searchInput.valueChanges
.debounceTime(300)
.distinctUntilChanged()
.subscribe(searchText => {
this.faqsFiltered = FuseUtils.filterArrayByString(this.faqs, searchText);
});
}
ngOnDestroy()
{
this.onFaqsChanged.unsubscribe();
}
setStep(index: number)
{
this.step = index;
}
nextStep()
{
this.step++;
}
prevStep()
{
this.step--;
}
}