Skip to content

Commit

Permalink
feat(example app): add directive to fix material list options deselec…
Browse files Browse the repository at this point in the history
…ting themselves when navigating away from the page
  • Loading branch information
MrWolfZ committed Apr 15, 2018
1 parent 33776a6 commit e7e4896
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions example-app/src/app/material/mat-list-option-fix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import { Directive, Host, OnDestroy } from '@angular/core';
import { MatListOption } from '@angular/material/list';

@Directive({
selector: 'mat-list-option',
})
export class MatListOptionFixDirective implements OnDestroy {
constructor(@Host() private matDirective: MatListOption) { }

ngOnDestroy() {
this.matDirective.selectionList = { _reportValueChange: () => void 0 } as any;
}
}
3 changes: 3 additions & 0 deletions example-app/src/app/material/material.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {

import { CustomErrorStateMatcherDirective } from './error-state-matcher';
import { NgrxMatSelectValueAccessor } from './mat-select-value-accessor';
import { MatListOptionFixDirective } from './mat-list-option-fix';

@NgModule({
imports: [
Expand All @@ -36,6 +37,7 @@ import { NgrxMatSelectValueAccessor } from './mat-select-value-accessor';
declarations: [
NgrxMatSelectValueAccessor,
CustomErrorStateMatcherDirective,
MatListOptionFixDirective,
],
exports: [
MatInputModule,
Expand All @@ -52,6 +54,7 @@ import { NgrxMatSelectValueAccessor } from './mat-select-value-accessor';
MatNativeDateModule,
NgrxMatSelectValueAccessor,
CustomErrorStateMatcherDirective,
MatListOptionFixDirective,
],
providers: [
{ provide: MAT_PLACEHOLDER_GLOBAL_OPTIONS, useValue: { float: 'always' } }
Expand Down

0 comments on commit e7e4896

Please sign in to comment.