Title: Allow host binding to feed inputs to host directives · Issue #50510 · angular/angular · GitHub
Open Graph Title: Allow host binding to feed inputs to host directives · Issue #50510 · angular/angular
X Title: Allow host binding to feed inputs to host directives · Issue #50510 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? No Description If a directive (let's named it ReusableDirective) exposes a required input (foo), and is used as a host directive by another directive (Comp...
Open Graph Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? No Description If a directive (let's named it ReusableDirective) exposes a required input (foo), and is used as a h...
X Description: Which @angular/* package(s) are the source of the bug? core Is this a regression? No Description If a directive (let's named it ReusableDirective) exposes a required input (foo), and is used as...
Opengraph URL: https://github.com/angular/angular/issues/50510
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Allow host binding to feed inputs to host directives","articleBody":"### Which @angular/* package(s) are the source of the bug?\r\n\r\ncore\r\n\r\n### Is this a regression?\r\n\r\nNo\r\n\r\n### Description\r\n\r\nIf a directive (let's named it `ReusableDirective`) exposes a required input (`foo`), and is used as a host directive by another directive (`ComposedDirective`), then the compiler forces the composed directive to expose the required input. \r\n\r\nThis is problematic when the whole point of the composed directive is precisely to provide a default or computed value for the required input. \r\n\r\nFor example: \r\n\r\n```ts\r\n@Directive({\r\n selector: '[app-reusable]',\r\n standalone: true,\r\n})\r\nclass ReusableDirective {\r\n @Input({ required: true }) foo!: string;\r\n\r\n // do something useful with foo here, but that's irrelevant\r\n}\r\n\r\n@Directive({\r\n selector: '[app-composed]',\r\n standalone: true,\r\n hostDirectives: [ReusableDirective],\r\n})\r\nclass ComposedDirective {\r\n constructor(reusable: ReusableDirective) {\r\n reusable.foo = 'hello';\r\n }\r\n}\r\n```\r\n\r\n### Please provide a link to a minimal reproduction of the bug\r\n\r\nhttps://stackblitz.com/edit/stackblitz-starters-85nxmu?description=An%20angular-cli%20project%20based%20on%20@angular/animations,%20@angular/common,%20@angular/compiler,%20@angular/core,%20@angular/forms,%20@angular/platform-browser,%20@angular/platform-browser-dynamic,%20@angular/router,%20core-js,%20rxjs,%20tslib%20and%20zone.js&file=src%2Fmain.ts&title=Angular%20Starter\r\n\r\n### Please provide the exception or error you saw\r\n\r\n```\r\nRequired input 'foo' from host directive ReusableDirective must be exposed.\r\n```\r\n\r\n\r\n### Please provide the environment you discovered this bug in (run `ng version`)\r\n\r\n```\r\nAngular CLI: 16.0.2\r\nNode: 18.16.0\r\nPackage Manager: yarn 1.22.19\r\nOS: darwin x64\r\n\r\nAngular: 16.0.2\r\n... animations, cli, common, compiler, compiler-cli, core, forms\r\n... localize, platform-browser, platform-browser-dynamic, router\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1600.2\r\n@angular-devkit/build-angular 16.0.2\r\n@angular-devkit/core 16.0.2\r\n@angular-devkit/schematics 16.0.2\r\n@angular/cdk 16.0.1\r\n@schematics/angular 16.0.2\r\nrxjs 7.8.1\r\ntypescript 5.0.4\r\n```\r\n\r\n\r\n### Anything else?\r\n\r\nThis just hit me in a real situation: ng-bootstrap's typeahead directive's `ngbTypeahead` input is marked as requird in the latest version, and we have several custom `fooTypeahead` and `barTypeahead` directives which simply use ngbTypeahead as a host directive and provide this required input. ","author":{"url":"https://github.com/jnizet","@type":"Person","name":"jnizet"},"datePublished":"2023-05-30T06:29:12Z","url":"https://github.com/angular/angular/issues/50510"}
| 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:c3651daf-1881-1af3-2709-2c4032c078bc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E50A:22DB35:12317C8:175A130:6B010DED |
| html-safe-nonce | 257d488f076263b41d7f22b1389995624f8b298971ea4c8d6975359fc0060678 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTBBOjIyREIzNToxMjMxN0M4OjE3NUExMzA6NkIwMTBERUQiLCJ2aXNpdG9yX2lkIjoiNTI0Nzg3NDMwMTQzNjE2OTcwOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7b40c2a16bff4a46e73cacc4e3a5ba734bfd244d02c544b0dad24fd908b9bd44 |
| hovercard-subject-tag | issue:1731595275 |
| 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/50510/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6a11d32e8e32d4d039b84167311312cec7fb1b1610f9902623e9cb831e8b2ecb/angular/angular/issues/50510 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6a11d32e8e32d4d039b84167311312cec7fb1b1610f9902623e9cb831e8b2ecb/angular/angular/issues/50510 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? core Is this a regression? No Description If a directive (let's named it ReusableDirective) exposes a required input (foo), and is used as a h... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jnizet |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width