Title: Support arrow functions in template syntax · Issue #14129 · angular/angular · GitHub
Open Graph Title: Support arrow functions in template syntax · Issue #14129 · angular/angular
X Title: Support arrow functions in template syntax · Issue #14129 · angular/angular
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
Open Graph 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 i...
X 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 determini...
Opengraph URL: https://github.com/angular/angular/issues/14129
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support arrow functions in template syntax","articleBody":"It's not uncommon for a component to take as input a transformation function or predicate function. \r\n\r\nFor example, [this PR for `@angular/forms`](https://github.com/angular/angular/pull/13349) adds an `@Input` for a predicate function for determining if two options in a `\u003cselect>` are equal. Right now, this looks something like:\r\n```\r\n\u003cselect [compareWith]=\"equals\" [(ngModel)]=\"selectedCountries\"> ...\r\n\r\nequals = (a: Country, b: Country) => {\r\n return a.id === b.id;\r\n};\r\n```\r\n\r\nWith this feature, this could be written as\r\n```html\r\n\u003cselect [compareWith]=\"(a, b) => a.id == b.id\" [(ngModel)]=\"selectedCountries\"> ...\r\n```\r\n\r\nThere are other places in Angular Material where we're looking to add similar API, e.g., datepicker with something like:\r\n```html\r\n\u003cmd-datepicker [allowedDateFilter]=\"d => isWeekend(d)\">\r\n```\r\n\r\nOr autocomplete, where the component needs to take an arbitrary value and know what string to write into the text input:\r\n```html\r\n\u003cmd-autocomplete [displayWith]=\"value => value.getFullName()\">\r\n```\r\n\r\nThis would have to account for:\r\n* Functions with multiple arguments (`(a, b) => a + b`)\r\n* Functions with param names that already exist in the context (`\u003cmy-x #x [uniq]=\"x => x.id\">`)\r\n* Functions that return an object literal (`x => ({name: x})`)\r\n* Invoking functions on the context (`x => isActive(x)`\r\n* Passing functions through a pipe (`x => x.activate() | debounce`)\r\n\r\nFYI @mhevery for planning","author":{"url":"https://github.com/jelbourn","@type":"Person","name":"jelbourn"},"datePublished":"2017-01-27T00:24:38Z","url":"https://github.com/angular/angular/issues/14129"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:57b436d2-9cd7-ea29-d903-eeb6631306ae |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 82A0:358871:12B765A:18B20DB:6B01189B |
| html-safe-nonce | 1434b4b23bfaeccae8c570c25edaacac3cab2c145d008d956941101927e356bc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkEwOjM1ODg3MToxMkI3NjVBOjE4QjIwREI6NkIwMTE4OUIiLCJ2aXNpdG9yX2lkIjoiMTA5Nzc5NjIzNjgxMzA4MDczMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4813a9f7ee6153505a7a78fa21d38bff0cf9a7ba41934f54f93eb737ca66c7b5 |
| hovercard-subject-tag | issue:203529178 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/14129/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3f768e89785d0d41232b063f33cba95314e69ce56656108ab7b87c71ab7a4163/angular/angular/issues/14129 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3f768e89785d0d41232b063f33cba95314e69ce56656108ab7b87c71ab7a4163/angular/angular/issues/14129 |
| og:image:alt | 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 i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jelbourn |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width