[FR] Make components subclassable without template
- Lingua principale
- TypeScript
- Stelle
- 101k
- Fork
- 27.5k
- Merge medio
- 1g 19h
- PR unite (30g)
- 288
Descrizione
### Which @angular/* package(s) are relevant/related to the feature request?
core
### Description
Angular lately added support for subclassing a component. It is thus now possible for a downstream-app to override a component's base-implementation in a lib. According to the docs I read, all you have to do is declare the same `selector`. Unfortunately, though, the subclass requires `template` or `templateUrl` -- without it, I get this error:
```
error NG2001: component is missing a template
```
My app-code doesn't have access to the lib's template-file (declared there via `templateUrl`) and IMHO I should not be forced to re-declare the template, if I do not want to replace it (but inherit it the way it is in the super-component).
The component-class contains the UI-logic. It should be easily possible for a downstream-lib/-app to customize this logic, i.e. override protected/public methods, without touching the UI (i.e. without re-declaring a template).
### Proposed solution
Make the `@Component(...)`-annotation's `template` and `templateUrl` optional for component-subclasses. A component-subclass should easily be able to override UI-logic without providing its own template.
### Alternatives considered
We tried to extract the UI-logic from the component into a stateful service which is associated 1-to-1 with its component. This, however, doesn't work either -- hence, I opened this other feature-request: https://github.com/angular/angular/issues/47899
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia dal comportamento del core di Angular riguardo all'ereditarietà e alla compilazione dei componenti, in relazione all'errore NG2001 segnalato. Riproduci un componente derivato senza template né templateUrl, quindi traccia come viene gestito il template della superclasse. Il lavoro è completato quando una sottoclasse di componente può sovrascrivere la logica dell'UI senza ridichiarare il template ereditato, con una copertura per il comportamento supportato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, typescript
- Ambito
- frontend
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100