René's URL Explorer Experiment


Title: Proposal to separate concerns of child control construction and parent ControlContainer mapping. · Issue #10195 · angular/angular · GitHub

Open Graph Title: Proposal to separate concerns of child control construction and parent ControlContainer mapping. · Issue #10195 · angular/angular

X Title: Proposal to separate concerns of child control construction and parent ControlContainer mapping. · Issue #10195 · angular/angular

Description: I'm submitting a ... (check one with "x") [ ] bug report [X] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question Current be...

Open Graph Description: I'm submitting a ... (check one with "x") [ ] bug report [X] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/ma...

X Description: I'm submitting a ... (check one with "x") [ ] bug report [X] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/angula...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal to separate concerns of child control construction and parent ControlContainer mapping.","articleBody":"**I'm submitting a ...**  (check one with \"x\")\n\n```\n[ ] bug report\n[X] feature request\n[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\n```\n\n**Current behavior**\n_Reactive forms:_\nThere is no built-in mechanism for separating the concerns of constructing a child control vs. mapping that hierarchy to a parent ControlContainer.  I have two choices to handle this dynamic form mapping myself:\n- In the parent I can wire myself up to the proper lifecycle events to dynamically bind that child control to the correct parent member.  I have to select the ViewChild, then implement OnChanges, tracking an initial wire-up flag.\n- In the child I can inject in the parent ControlContainer and receive the name/index of the parent.\n\n**Expected/desired behavior**\nA directive (or extension to existing __Name directives) which maps the value from the child control could remove this complexity and allow the child to specify the control while the directive (used in the parent component) would handle the mapping.\n\nIn other words, in the template I want to say this:\n\n``` html\n\u003caddress #homeAddress formControlName=\"homeAddress\" [childControl]=\"homeAddress.control\">\u003c/address>\n\u003caddress #workAddress formControlName=\"workAddress\" [childControl]=\"workAddress.control\">\u003c/address>\n```\n\nHere the value associated with childControl would be set on the parent ControlContainer (either array or group) based on the formControlName.\n\n**What is the motivation / use case for changing the behavior?**\nTake a reusable address component for an example that may build up a FormGroup of line1, line2, city, state, and zip, as well as several validators.  I may want to use this component in several locations, perhaps on a page with a parent FormGroup with 'home' and 'work' children, and then on another page that allows me to add any number of saved shipping addresses to a FormArray.\n\n**Implementation**\nThis could be accomplished by adding an Input on the applicable directives (FormGroupName, FormControlName, NgControl).  If set, then the control passed to it would be mapped to the parent ControlContainer.  Here is a working hack I was toying with just for the sake of showing the interaction points and allowing me to use the above template syntax.  The hack points are that it replaces those directives' ngOnChanges methods and accesses the private _parent.\n\n``` ts\n@Directive({\n    selector: '[abcFormControl]'\n})\nexport class AbcFormControl implements OnChanges /*implements ControlValueAccessor*/ {\n    constructor( @Optional() @Self() formGroupName: FormGroupName, @Optional() @Self() formArrayName: FormArrayName, @Optional() @Self() ngControl: NgControl) {\n        this._otherDirective = \u003cany>(formGroupName ? formGroupName : formArrayName ? formArrayName : ngControl);\n        this._oldOnChanges = this._otherDirective.ngOnChanges;\n        this._otherDirective.ngOnChanges = (changes: SimpleChanges) => this._newOnChanges(changes);\n    }\n\n    @Input() abcFormControl: AbstractControl;\n    private _otherDirective: any;\n    private _oldOnChanges: (changes: SimpleChanges) => any;\n    private _delayedChanges: SimpleChanges | null;\n\n    private _newOnChanges(changes: SimpleChanges) {\n        if (!this.abcFormControl)\n            this._delayedChanges = changes;\n    }\n\n    ngOnChanges(changes: SimpleChanges) {\n        if (changes[\"abcFormControl\"] && this._otherDirective._parent) {\n            if (changes[\"abcFormControl\"].previousValue instanceof AbstractControl)\n                this._remove();\n            this._add();\n        }\n        if (this._delayedChanges) {\n            this._oldOnChanges.call(this._otherDirective, this._delayedChanges);\n            this._delayedChanges = null;\n        }\n    }\n\n    private _add(): void {\n        if (this._otherDirective._parent.control instanceof FormGroup)\n            (\u003cFormGroup>this._otherDirective._parent.control).addControl(this._otherDirective.name, this.abcFormControl);\n        else\n            (\u003cFormArray>this._otherDirective._parent.control).insert(parseInt(this._otherDirective.name), this.abcFormControl);\n    }\n\n    private _remove(): void {\n        if (this._otherDirective._parent.control instanceof FormGroup)\n            (\u003cFormGroup>this._otherDirective._parent.control).removeControl(this._otherDirective.name);\n        else\n            (\u003cFormArray>this._otherDirective._parent.control).removeAt(parseInt(this._otherDirective.name));\n    }\n}\n```\n\nThanks for considering!\n\n**Please tell us about your environment:**\n- **Angular version:** 2.0.0-rc.4\n- **Browser:** [Chrome 51] \n- **Language:** [TypeScript 2.0.0] \n","author":{"url":"https://github.com/EricABC","@type":"Person","name":"EricABC"},"datePublished":"2016-07-20T22:45:37Z","url":"https://github.com/angular/angular/issues/10195"}

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:fa6bb323-5586-0670-1bc0-8a1167d45877
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC8AA:2D96F1:1235D89:182230E:6B01187C
html-safe-noncecd1ab6f1b0edd6b12f58a3434855394161effb6b11b5eb6342f504750ef1283f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOEFBOjJEOTZGMToxMjM1RDg5OjE4MjIzMEU6NkIwMTE4N0MiLCJ2aXNpdG9yX2lkIjoiNDc5NjUxNjA5ODEwNTIxOTE5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac19d4b5868c43793f7fcb8e9520d500544a9de977594c84e3e2844577e68d1d3b
hovercard-subject-tagissue:166699976
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/10195/issue_layout
twitter:imagehttps://opengraph.githubassets.com/74e9c4683360b9dcd623cc118dfaad97c3ff2e1a8131c616b46527260ebb3282/angular/angular/issues/10195
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/74e9c4683360b9dcd623cc118dfaad97c3ff2e1a8131c616b46527260ebb3282/angular/angular/issues/10195
og:image:altI'm submitting a ... (check one with "x") [ ] bug report [X] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/ma...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameEricABC
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/10195#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F10195
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%2F10195
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/10195
Reloadhttps://github.com/angular/angular/issues/10195
Reloadhttps://github.com/angular/angular/issues/10195
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues835 (835)https://github.com/angular/angular/issues
Pull requests141 (141)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/10195
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/10195
Proposal to separate concerns of child control construction and parent ControlContainer mapping.https://github.com/angular/angular/issues/10195#top
area: formshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20forms%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/EricABC
EricABChttps://github.com/EricABC
on Jul 20, 2016https://github.com/angular/angular/issues/10195#issue-166699976
pkozlowski-opensourcehttps://github.com/pkozlowski-opensource
area: formshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20forms%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
on Sep 7, 2016https://github.com/angular/angular/issues/10195#event-780837440
ngbothttps://github.com/apps/ngbot
Backloghttps://github.com/angular/angular/milestone/82
on Jan 23, 2018https://github.com/angular/angular/issues/10195#event-1437656265
https://github.com/apps/angular-robot
angular-robothttps://github.com/apps/angular-robot
on May 21, 2021https://github.com/angular/angular/issues/10195#issuecomment-846254110
documentationhttps://github.com/angular/angular/blob/e29eb8abfbfdfb793e08ac88e14b7ba6d2ff2136/docs/GITHUB_PROCESS.md#feature-request-process
angular-robothttps://github.com/apps/angular-robot
votes requiredhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22votes%20required%22
on May 21, 2021https://github.com/angular/angular/issues/10195#event-4781319164
https://github.com/apps/angular-robot
angular-robothttps://github.com/apps/angular-robot
on Jun 10, 2021https://github.com/angular/angular/issues/10195#issuecomment-858651370
communityhttps://angular.io/resources?category=community
packagehttps://angular.io/guide/creating-libraries
documentationhttps://github.com/angular/angular/blob/e29eb8abfbfdfb793e08ac88e14b7ba6d2ff2136/docs/GITHUB_PROCESS.md#feature-request-process
angular-robothttps://github.com/apps/angular-robot
insufficient voteshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22insufficient%20votes%22
on Jun 10, 2021https://github.com/angular/angular/issues/10195#event-4871652889
AndrewKushnirhttps://github.com/AndrewKushnir
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 10, 2021https://github.com/angular/angular/issues/10195#event-4874866147
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Jul 11, 2021https://github.com/angular/angular/issues/10195#issuecomment-877825813
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 Jul 11, 2021https://github.com/angular/angular/issues/10195#event-5004305008
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/10195
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/10195
area: formshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20forms%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
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

Viewport: width=device-width


URLs of crawlers that visited me.