Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(input)="filter()"
(focus)="filter()">
<mat-autocomplete requireSelection #auto="matAutocomplete">
@for (option of filteredOptions; track option) {
@for (option of filteredOptions(); track option) {
<mat-option [value]="option">{{option}}</mat-option>
}
</mat-autocomplete>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, ElementRef, ViewChild} from '@angular/core';
import {Component, ElementRef, signal, viewChild} from '@angular/core';
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatAutocompleteModule} from '@angular/material/autocomplete';
import {MatInputModule} from '@angular/material/input';
Expand All @@ -20,13 +20,13 @@ import {MatFormFieldModule} from '@angular/material/form-field';
],
})
export class AutocompleteRequireSelectionExample {
@ViewChild('input') input!: ElementRef<HTMLInputElement>;
input = viewChild.required<ElementRef<HTMLInputElement>>('input');
myControl = new FormControl('');
options: string[] = ['One', 'Two', 'Three', 'Four', 'Five'];
filteredOptions: string[] = this.options.slice();
filteredOptions = signal<string[]>(this.options.slice());

filter(): void {
const filterValue = this.input.nativeElement.value.toLowerCase();
this.filteredOptions = this.options.filter(o => o.toLowerCase().includes(filterValue));
const filterValue = this.input().nativeElement.value.toLowerCase();
this.filteredOptions.set(this.options.filter(o => o.toLowerCase().includes(filterValue)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="demo-section">
Button toggles badge visibility
<!-- #docregion mat-badge-hide -->
<button matButton="elevated" matBadge="7" [matBadgeHidden]="hidden" (click)="toggleBadgeVisibility()">
<button matButton="elevated" matBadge="7" [matBadgeHidden]="hidden()" (click)="toggleBadgeVisibility()">
Hide
</button>
<!-- #enddocregion mat-badge-hide -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {Component, signal} from '@angular/core';
import {MatIconModule} from '@angular/material/icon';
import {MatButtonModule} from '@angular/material/button';
import {MatBadgeModule} from '@angular/material/badge';
Expand All @@ -13,9 +13,9 @@ import {MatBadgeModule} from '@angular/material/badge';
imports: [MatBadgeModule, MatButtonModule, MatIconModule],
})
export class BadgeOverviewExample {
hidden = false;
hidden = signal(false);

toggleBadgeVisibility() {
this.hidden = !this.hidden;
this.hidden.update(hidden => !hidden);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, TemplateRef, ViewChild, inject} from '@angular/core';
import {Component, TemplateRef, inject, viewChild} from '@angular/core';
import {
MatBottomSheet,
MatBottomSheetConfig,
Expand All @@ -16,9 +16,9 @@ import {
export class BottomSheetHarnessExample {
readonly bottomSheet = inject(MatBottomSheet);

@ViewChild(TemplateRef) template!: TemplateRef<any>;
template = viewChild.required<TemplateRef<any>>(TemplateRef);

open(config?: MatBottomSheetConfig) {
return this.bottomSheet.open(this.template, config);
return this.bottomSheet.open(this.template(), config);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h4>Button Toggle inside of a Template-driven form</h4>
<mat-button-toggle value="italic">Italic</mat-button-toggle>
<mat-button-toggle value="underline">Underline</mat-button-toggle>
</mat-button-toggle-group>
<p>Chosen value is {{fontStyle}}</p>
<p>Chosen value is {{fontStyle()}}</p>
</section>

<section>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {Component, signal} from '@angular/core';
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MatButtonToggleModule} from '@angular/material/button-toggle';

Expand All @@ -12,5 +12,5 @@ import {MatButtonToggleModule} from '@angular/material/button-toggle';
})
export class ButtonToggleFormsExample {
fontStyleControl = new FormControl('');
fontStyle?: string;
fontStyle = signal<string | undefined>(undefined);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<button id="basic" type="button" matButton (click)="clicked = true">
<button id="basic" type="button" matButton (click)="clicked.set(true)">
Basic button
</button>
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe('ButtonHarnessExample', () => {

it('should click a button', async () => {
const button = await loader.getHarness(MatButtonHarness.with({text: 'Basic button'}));
expect(fixture.componentInstance.clicked).toBe(false);
expect(fixture.componentInstance.clicked()).toBe(false);
await button.click();
expect(fixture.componentInstance.clicked).toBe(true);
expect(fixture.componentInstance.clicked()).toBe(true);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {Component, signal} from '@angular/core';
import {MatButtonModule} from '@angular/material/button';

/**
Expand All @@ -10,5 +10,5 @@ import {MatButtonModule} from '@angular/material/button';
imports: [MatButtonModule],
})
export class ButtonHarnessExample {
clicked = false;
clicked = signal(false);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<mat-form-field class="example-form-field">
<mat-label>Clearable input</mat-label>
<input matInput type="text" [(ngModel)]="value">
@if (value) {
<button matSuffix matIconButton aria-label="Clear" (click)="value=''">
@if (value()) {
<button matSuffix matIconButton aria-label="Clear" (click)="value.set('')">
<mat-icon>close</mat-icon>
</button>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {Component, signal} from '@angular/core';
import {MatIconModule} from '@angular/material/icon';
import {MatButtonModule} from '@angular/material/button';
import {FormsModule} from '@angular/forms';
Expand All @@ -15,5 +15,5 @@ import {MatFormFieldModule} from '@angular/material/form-field';
imports: [MatFormFieldModule, MatInputModule, FormsModule, MatButtonModule, MatIconModule],
})
export class InputClearableExample {
value = 'Clear me';
value = signal('Clear me');
}
Loading