better binding for global song filter
This commit is contained in:
@@ -5,6 +5,7 @@ import {RouterModule} from '@angular/router';
|
|||||||
import {FilterComponent} from './navigation/filter/filter.component';
|
import {FilterComponent} from './navigation/filter/filter.component';
|
||||||
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
|
||||||
import {LinkComponent} from './navigation/link/link.component';
|
import {LinkComponent} from './navigation/link/link.component';
|
||||||
|
import {FormsModule} from '@angular/forms';
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -16,7 +17,8 @@ import {LinkComponent} from './navigation/link/link.component';
|
|||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
RouterModule,
|
RouterModule,
|
||||||
FontAwesomeModule
|
FontAwesomeModule,
|
||||||
|
FormsModule
|
||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
NavigationComponent
|
NavigationComponent
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<input (input)="onInputChange($event.target.value)" placeholder="Suche">
|
<input (ngModelChange)="valueChange($event)" [ngModel]="value" placeholder="Suche">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Component} from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
import {Router} from '@angular/router';
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-filter',
|
selector: 'app-filter',
|
||||||
@@ -7,11 +7,15 @@ import {Router} from '@angular/router';
|
|||||||
styleUrls: ['./filter.component.less']
|
styleUrls: ['./filter.component.less']
|
||||||
})
|
})
|
||||||
export class FilterComponent {
|
export class FilterComponent {
|
||||||
|
public value: string;
|
||||||
|
|
||||||
constructor(private router: Router) {
|
constructor(private router: Router, activatedRoute: ActivatedRoute) {
|
||||||
|
activatedRoute.queryParams.subscribe(_ => {
|
||||||
|
if (_.q) this.value = _.q;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async onInputChange(text: string): Promise<void> {
|
public async valueChange(text: string): Promise<void> {
|
||||||
const route = text
|
const route = text
|
||||||
? this.router.createUrlTree(['songs'], {queryParams: {q: text}})
|
? this.router.createUrlTree(['songs'], {queryParams: {q: text}})
|
||||||
: this.router.createUrlTree(['songs']);
|
: this.router.createUrlTree(['songs']);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user