-
Notifications
You must be signed in to change notification settings - Fork 27k
Closed
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: binding & interpolationIssue related to property/attribute binding or text interpolationIssue related to property/attribute binding or text interpolationfeatureIssue that requests a new featureIssue that requests a new featurehotlist: components teamRelated to Angular CDK or Angular MaterialRelated to Angular CDK or Angular Materialstate: has PR
Milestone
Description
It's not uncommon for a component to take as input a transformation function or predicate function.
For example, this PR for @angular/forms adds an @Input for a predicate function for determining if two options in a <select> are equal. Right now, this looks something like:
<select [compareWith]="equals" [(ngModel)]="selectedCountries"> ...
equals = (a: Country, b: Country) => {
return a.id === b.id;
};
With this feature, this could be written as
<select [compareWith]="(a, b) => a.id == b.id" [(ngModel)]="selectedCountries"> ...There are other places in Angular Material where we're looking to add similar API, e.g., datepicker with something like:
<md-datepicker [allowedDateFilter]="d => isWeekend(d)">Or autocomplete, where the component needs to take an arbitrary value and know what string to write into the text input:
<md-autocomplete [displayWith]="value => value.getFullName()">This would have to account for:
- Functions with multiple arguments (
(a, b) => a + b) - Functions with param names that already exist in the context (
<my-x #x [uniq]="x => x.id">) - Functions that return an object literal (
x => ({name: x})) - Invoking functions on the context (
x => isActive(x) - Passing functions through a pipe (
x => x.activate() | debounce)
FYI @mhevery for planning
blyndcide, OskarKlintrot, kesarion, ReubenNahouraii, timkolotov and 142 morestalniy, oskarols and aceArt-GmbHkeatkeat87, luketanner, dylhunn and aceArt-GmbHamitbeck and aceArt-GmbH
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: binding & interpolationIssue related to property/attribute binding or text interpolationIssue related to property/attribute binding or text interpolationfeatureIssue that requests a new featureIssue that requests a new featurehotlist: components teamRelated to Angular CDK or Angular MaterialRelated to Angular CDK or Angular Materialstate: has PR