Title: Extend/Inherit angular2 components annotations · Issue #7968 · angular/angular · GitHub
Open Graph Title: Extend/Inherit angular2 components annotations · Issue #7968 · angular/angular
X Title: Extend/Inherit angular2 components annotations · Issue #7968 · angular/angular
Description: I would like to create extensions for some components already deployed in Angular 2, without having to rewrite them almost completely, as the base component could undergo changes and wish these changes were also reflected in its derived ...
Open Graph Description: I would like to create extensions for some components already deployed in Angular 2, without having to rewrite them almost completely, as the base component could undergo changes and wish these cha...
X Description: I would like to create extensions for some components already deployed in Angular 2, without having to rewrite them almost completely, as the base component could undergo changes and wish these cha...
Opengraph URL: https://github.com/angular/angular/issues/7968
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Extend/Inherit angular2 components annotations","articleBody":"I would like to create extensions for some components already deployed in Angular 2, without having to rewrite them almost completely, as the base component could undergo changes and wish these changes were also reflected in its derived components.\r\n\r\n**Example**\r\n\r\n**I created this simple example to try to explain better the problem:**\r\n\r\nWith the following base component `app/base-panel.component.ts`:\r\n\r\n```typescript\r\nimport {Component, Input} from 'angular2/core';\r\n\r\n@Component({\r\n selector: 'base-panel',\r\n template: '\u003cdiv class=\"panel\" [style.background-color]=\"color\" (click)=\"onClick($event)\">{{content}}\u003c/div>',\r\n styles: [`\r\n .panel{\r\n padding: 50px;\r\n }\r\n `]\r\n})\r\nexport class BasePanelComponent { \r\n\r\n @Input() content: string;\r\n\r\n color: string = \"red\";\r\n\r\n onClick(event){\r\n console.log(\"Click color: \" + this.color);\r\n }\r\n}\r\n```\r\n\r\nWould you like to create another derivative component only alter, for example, a basic component behavior in the case of the example color, `app/my-panel.component.ts`:\r\n\r\n```typescript\r\nimport {Component} from 'angular2/core';\r\nimport {BasePanelComponent} from './base-panel.component'\r\n\r\n@Component({\r\n selector: 'my-panel',\r\n template: '\u003cdiv class=\"panel\" [style.background-color]=\"color\" (click)=\"onClick($event)\">{{content}}\u003c/div>',\r\n styles: [`\r\n .panel{\r\n padding: 50px;\r\n }\r\n `]\r\n})\r\nexport class MyPanelComponent extends BasePanelComponent{\r\n\r\n constructor(){\r\n this.color = \"blue\";\r\n }\r\n}\r\n```\r\n\r\n[Example in Plunker](http://plnkr.co/edit/bWa1JmH7NaSaJffLsl0x?p=preview)\r\n\r\n**Problem/Limitation**\r\n\r\nAs you can see in the implementation of the derivative component `app/my-panel.component.ts`, much of the implementation was repeated, and the single part really inherited was the `class` `BasePanelComponent`, but the annotation `@Component` had to basically be completely repeated, not just the changed portions, as the `selector: 'my-panel'`.\r\n\r\n**Feature request**\r\n\r\nAfter a few days of research around this possible limitation (question on [StackOverflow ](http://stackoverflow.com/q/36475626/2290538)and [StackOverflowPt (my native language)](http://pt.stackoverflow.com/q/121960/2998)), concludes that even the current version there is no mechanism for the annotations inheritance. So I wonder if it is possible to be implemented this possibility/feature functionality for future versions of the angular library?\r\n","author":{"url":"https://github.com/fernandocode","@type":"Person","name":"fernandocode"},"datePublished":"2016-04-08T12:09:34Z","url":"https://github.com/angular/angular/issues/7968"}
| 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:17358d03-40b4-c6b6-10d9-0a17475a0e0c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9C8C:EDA7A:647A42:819A0A:6B00DFEC |
| html-safe-nonce | b021bdcc0b4dc4a015e6cbb68f9ad1d20dbcb86a955d50757f7ccbc555063961 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzhDOkVEQTdBOjY0N0E0Mjo4MTlBMEE6NkIwMERGRUMiLCJ2aXNpdG9yX2lkIjoiODUzOTE2ODc2NzU1MTI2Njc5NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 673c71a382f9c0ddc7c36f4a8e6678e19c71228309c21a9bdb68268a67496474 |
| hovercard-subject-tag | issue:146911343 |
| 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/7968/issue_layout |
| twitter:image | https://opengraph.githubassets.com/53acf85238cdbd8d54fdc7689958be6d281295d65c977d68a34ee4d36e95b04f/angular/angular/issues/7968 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/53acf85238cdbd8d54fdc7689958be6d281295d65c977d68a34ee4d36e95b04f/angular/angular/issues/7968 |
| og:image:alt | I would like to create extensions for some components already deployed in Angular 2, without having to rewrite them almost completely, as the base component could undergo changes and wish these cha... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fernandocode |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width