René's URL Explorer Experiment


Title: Proposal: Need ability to add directives to host elements in component declaration. · Issue #8785 · angular/angular · GitHub

Open Graph Title: Proposal: Need ability to add directives to host elements in component declaration. · Issue #8785 · angular/angular

X Title: Proposal: Need ability to add directives to host elements in component declaration. · Issue #8785 · angular/angular

Description: I've been digging into Angular 2 and have run into a potential road block for extending certain kinds of components. In the the following example, I have a button component, and a directive that will apply styles based on touch events. T...

Open Graph Description: I've been digging into Angular 2 and have run into a potential road block for extending certain kinds of components. In the the following example, I have a button component, and a directive that wi...

X Description: I've been digging into Angular 2 and have run into a potential road block for extending certain kinds of components. In the the following example, I have a button component, and a directive tha...

Opengraph URL: https://github.com/angular/angular/issues/8785

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: Need ability to add directives to host elements in component declaration.","articleBody":"I've been digging into Angular 2 and have run into a potential road block for extending certain kinds of components.\n\nIn the the following example, I have a button component, and a directive that will apply styles based on touch events. There will be many other objects other than just the button that will inherit the exact same touch behavior. I've explored my options, and I'm at a loss:\n- Directly extend a TouchClass. This seems less than ideal since typescript doesn't support multiple class inheritance, and I'd also like to expose the behavior to consumers for use in their own classes.\n- Fake multiple class inheritance through an interface. This seems like a hack and requires me to redeclare a shim api on every class I'm trying to mix into. https://www.stevefenton.co.uk/2014/02/TypeScript-Mixins-Part-One/\n- Create a helper function that does it through a service directly on elementRef.nativeElement in the component constructor. I really don't want to do this since it states in the docs that nativeElement will be null when running in a worker, and that capability is something I'm the most excited about.\n\nWithout getting too deep into the guts, I'd presume that the componentMetadata is available during the components compile time, and that the host property could be scanned for additional directives that could be added dynamically and compiled at the same time. This would allow you to do mixins the angular way: using composable directives to extend functionality, and doing it without breaking view projection. Short example below.\n\n**Current behavior**\nDeclaring a directive in componentMetadata.host treats it as a regular attribute\n\n**Expected/desired behavior**\nThe directive declared in host would be processed at compile time.\n\n``` typescript\n/**\n * App\n */\n@Component({\n    selector: 'app-component',\n    template: '\u003cg-btn>TEST\u003c/g-btn>',\n    directives: [gBtn, gTouch]\n})\n\nexport class AppComponent {\n    constructor() {\n\n    }\n}\n\n/**\n * Touch Directive\n * Will be used in lots and lots of components\n */\n@Directive({\n    selector: '[g-touch]',\n    host: { \n        '(touchstart)': '...',\n        '(touchend)': '...',\n        '(touchmove)': '...',\n        '(touchcancel)': '...'\n    }\n})\n\nexport class gTouch {\n    constructor() {\n\n    }\n}\n\n/**\n * Simple button component\n */\n@Component({\n    selector: 'g-btn',\n    template: '\u003cng-content>\u003c/ng-content>',\n    host: {\n        'role': 'button',\n        // WOULD LOVE FOR THIS TO COMPILE THE DIRECTIVE!\n        // right now it just adds an attribute called g-touch\n        'g-touch': ' ' \n    }\n})\n\nexport class gBtn {\n\n    constructor() {\n\n    }\n}\n```\n\nSome ideas of how this could work:\n\n``` typescript\n// Option 1: just scan the host properties for directives.\n// This would be my ideal, simple and understandable\n@Component({\n    selector: 'g-btn',\n    template: '\u003cng-content>\u003c/ng-content>',\n    host: {\n        'role': 'button',\n        'g-touch': true // or {prop: 'foo'} or string\n    }\n})\n\n// Option 2: definitely more declarative using a hostDirectives property\n// more declarative, albeit more annoying to have to reimport the touch class\n@Component({\n    selector: 'g-btn',\n    template: '\u003cng-content>\u003c/ng-content>',\n    hostDirectives: gTouch,\n    host: {\n        'role': 'button',\n        'g-touch': true\n    }\n})\n\n// Option 3: declare host directives as its own thing, still just\n// use keys pointing to bool, obj, or string\n@Component({\n    selector: 'g-btn',\n    template: '\u003cng-content>\u003c/ng-content>',\n    hostDirectives: {\n        'g-touch': {someOption: someOption}\n    },\n    host: {\n        'role': 'button',\n    }\n});\n\n// Option 4: Not a huge fan of this one, but understandable if\n// people want to keep one host property\n@Component({\n    selector: 'g-btn',\n    template: '\u003cng-content>\u003c/ng-content>',\n    host: {\n        'role': 'button',\n        _directives: {\n            'g-touch': true\n        }\n    }\n});\n```\n\nThanks everyone, Angular 2 is looking great!. Let me know if theres something I'm missing.\n","author":{"url":"https://github.com/jamesmfriedman","@type":"Person","name":"jamesmfriedman"},"datePublished":"2016-05-23T13:07:27Z","url":"https://github.com/angular/angular/issues/8785"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:1ccaa8e6-8ee4-e441-aa53-4d94d70ff1ea
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCD24:1F6D:F1D8A:144937:6B04805C
html-safe-noncec806088f2bf73915f2a87bac94d2785eb8283a2bdbc95bffc27a705465561912
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDI0OjFGNkQ6RjFEOEE6MTQ0OTM3OjZCMDQ4MDVDIiwidmlzaXRvcl9pZCI6IjE2NDg3OTkwOTg3NTA2NjQ3OTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf650a4782d79f96baa45abae1e09bc950ac975c760e4beb2b89f1f15a2528f77
hovercard-subject-tagissue:156276209
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/8785/issue_layout
twitter:imagehttps://opengraph.githubassets.com/2c27f0a1fb38a48156c70b3d7a02236b4e832cd9225e3adf2f2c5f98ed35ea0a/angular/angular/issues/8785
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/2c27f0a1fb38a48156c70b3d7a02236b4e832cd9225e3adf2f2c5f98ed35ea0a/angular/angular/issues/8785
og:image:altI've been digging into Angular 2 and have run into a potential road block for extending certain kinds of components. In the the following example, I have a button component, and a directive that wi...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejamesmfriedman
hostnamegithub.com
expected-hostnamegithub.com
None0366ddfb372682a32e92a5d86155cb08fa83e5bbe79953a968789f2f7e24c511
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseed3f2e01f6b7672780c586c8af0e72726374d7b6
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/8785#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F8785
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F8785
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/8785
Reloadhttps://github.com/angular/angular/issues/8785
Reloadhttps://github.com/angular/angular/issues/8785
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues839 (839)https://github.com/angular/angular/issues
Pull requests137 (137)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/8785
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/8785
Proposal: Need ability to add directives to host elements in component declaration.https://github.com/angular/angular/issues/8785#top
https://github.com/crisbeto
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
core: directive matchinghttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22core%3A%20directive%20matching%22
core: host and host bindingshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22core%3A%20host%20and%20host%20bindings%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%22
state: has PRhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20has%20PR%22
v15 feature freeze blockershttps://github.com/angular/angular/milestone/115
https://github.com/jamesmfriedman
jamesmfriedmanhttps://github.com/jamesmfriedman
on May 23, 2016https://github.com/angular/angular/issues/8785#issue-156276209
https://www.stevefenton.co.uk/2014/02/TypeScript-Mixins-Part-One/https://www.stevefenton.co.uk/2014/02/TypeScript-Mixins-Part-One/
Nexthttps://github.com/angular/angular/issues/8785?timeline_page=1
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
comp: corehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22comp%3A%20core%22
on Jun 16, 2016https://github.com/angular/angular/issues/8785#event-694273374
https://github.com/Andy1605
Andy1605https://github.com/Andy1605
on Jul 7, 2016https://github.com/angular/angular/issues/8785#issuecomment-231026434
https://plnkr.co/edit/J65THEMic0yhObt1LkCu?p=infohttps://plnkr.co/edit/J65THEMic0yhObt1LkCu?p=info
http://stackoverflow.com/questions/37148080/use-angular2-directive-in-host-of-another-directivehttp://stackoverflow.com/questions/37148080/use-angular2-directive-in-host-of-another-directive
mheveryhttps://github.com/mhevery
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
comp: corehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22comp%3A%20core%22
on Sep 7, 2016https://github.com/angular/angular/issues/8785#event-781549376
https://github.com/jamesmfriedman
jamesmfriedmanhttps://github.com/jamesmfriedman
on Sep 16, 2016https://github.com/angular/angular/issues/8785#issuecomment-247688594
@Andy1605https://github.com/Andy1605
https://github.com/jofran73
jofran73https://github.com/jofran73
on Sep 24, 2016https://github.com/angular/angular/issues/8785#issuecomment-249371628
https://github.com/Aaron-Pool
Aaron-Poolhttps://github.com/Aaron-Pool
on Oct 16, 2016https://github.com/angular/angular/issues/8785#issuecomment-254019544
angular/angular.js#15270https://github.com/angular/angular.js/issues/15270
https://github.com/oddlyfunctional
oddlyfunctionalhttps://github.com/oddlyfunctional
on Nov 1, 2016https://github.com/angular/angular/issues/8785#issuecomment-257579275
https://github.com/jjstreet
jjstreethttps://github.com/jjstreet
on Nov 1, 2016https://github.com/angular/angular/issues/8785#issuecomment-257624061
https://github.com/Aaron-Pool
Aaron-Poolhttps://github.com/Aaron-Pool
on Nov 1, 2016https://github.com/angular/angular/issues/8785#issuecomment-257658281
@jjstreethttps://github.com/jjstreet
@pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
https://github.com/jamesmfriedman
jamesmfriedmanhttps://github.com/jamesmfriedman
on Nov 1, 2016https://github.com/angular/angular/issues/8785#issuecomment-257659605
https://github.com/k3nsei
k3nseihttps://github.com/k3nsei
on Nov 14, 2016https://github.com/angular/angular/issues/8785#issuecomment-260296588
https://github.com/vlodko
vlodkohttps://github.com/vlodko
on Dec 14, 2016https://github.com/angular/angular/issues/8785#issuecomment-267019004
https://github.com/Aaron-Pool
Aaron-Poolhttps://github.com/Aaron-Pool
on Dec 14, 2016https://github.com/angular/angular/issues/8785#issuecomment-267099992
alxhubhttps://github.com/alxhub
on Aug 22, 2022https://github.com/angular/angular/issues/8785#event-7236918619
refactor(compiler): add support for host directives (#46868)https://github.com/angular/angular/commit/54ceed53e21a6a899617b626becc51ffb1059178
#46868https://github.com/angular/angular/pull/46868
54ceed5https://github.com/angular/angular/commit/54ceed53e21a6a899617b626becc51ffb1059178
https://github.com/framasev
framasevhttps://github.com/framasev
on Aug 31, 2022https://github.com/angular/angular/issues/8785#issuecomment-1232910791
crisbetohttps://github.com/crisbeto
Backloghttps://github.com/angular/angular/milestone/82
v15 Feature Freezehttps://github.com/angular/angular/milestone/115
on Sep 12, 2022https://github.com/angular/angular/issues/8785#event-7369684321
crisbetohttps://github.com/crisbeto
on Oct 5, 2022https://github.com/angular/angular/issues/8785#event-7525529553
feat(core): enable the new directive composition APIhttps://github.com/crisbeto/angular/commit/6a8bd9f3ab16e656e8e0eb16e2c2bc5a9f9467bc
https://docs.github.com/articles/closing-issues-via-commit-messages
6a8bd9fhttps://github.com/crisbeto/angular/commit/6a8bd9f3ab16e656e8e0eb16e2c2bc5a9f9467bc
crisbetohttps://github.com/crisbeto
state: has PRhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20has%20PR%22
on Oct 5, 2022https://github.com/angular/angular/issues/8785#event-7528434005
jessicajaniukhttps://github.com/jessicajaniuk
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
db28badhttps://github.com/angular/angular/commit/db28badfe67f404e81dacd7c3131af105feb3412
on Oct 6, 2022https://github.com/angular/angular/issues/8785#event-7537576939
https://github.com/johncrim
johncrimhttps://github.com/johncrim
on Nov 3, 2022https://github.com/angular/angular/issues/8785#issuecomment-1302357100
@crisbetohttps://github.com/crisbeto
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Dec 4, 2022https://github.com/angular/angular/issues/8785#issuecomment-1336452713
automatic conversation locking policyhttps://github.com/angular/angular/blob/8f24bc9443b3872fe095d9f7f77b308a361a13b4/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Dec 4, 2022https://github.com/angular/angular/issues/8785#event-7948687538
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/8785
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/8785
crisbetohttps://github.com/crisbeto
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
core: directive matchinghttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22core%3A%20directive%20matching%22
core: host and host bindingshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22core%3A%20host%20and%20host%20bindings%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
feature: under considerationFeature request for which voting has completed and the request is now under considerationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%3A%20under%20consideration%22
state: has PRhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22state%3A%20has%20PR%22
v15 feature freeze blockershttps://github.com/angular/angular/milestone/115
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.