Comments (3)
Components with required inputs can be dynamically created, just make sure those inputs are set via .setInput()
before the component is change detected.
Note that it's not possible to dynamically create an arbitrary component in a guaranteed correct way. Any component can have assumptions about how it'll be created:
- with certain DI providers available
- with certain inputs available (required inputs)
- what types of values it accepts for its inputs
- as a child of a specific other component
- with specific content children
- with a certain directive applied (not possible to do dynamically)
To correctly create a component, you need to meet these requirements. I don't think having the required status of inputs available via ComponentMirror
is sufficient. For example, since you don't know the types of such inputs, how can you expect to provide values for them even if you know they're required?
The alternative is that you can not use signal inputs and stick with the old way.
Required inputs exist for non-signal inputs, too. If you fail to provide a value for one, the component will likely crash when it attempts to read it and gets an undefined
value.
from angular.
Closing as answered - I don't think there's any more action we can take with this issue.
from angular.
Hi,
Thanks for reading my issue and sorry for the late reply, I've been a bit busy.
I understand that the ComponentMirror interface will never bu fully sufficient to create an arbitrary component. But that begs the question: What decides what information goes into the interface and what information is left out?
I understand why compile time information like types can not be in the interface. But what makes, for example, templateName more useful to have in the interface than if an input is required? In my opinion it is not.
If I would have to guess; I think that the original aim of the ComponentMirror interface was to provide all the runtime information that is available about a component. But the interface was not extended when required inputs was introduced as runtime information. I believe this is a mistake, but welcome any explanation that would change my conclusion.
from angular.
Related Issues (20)
- Differences in change detection between components using @for vs *ngFor HOT 1
- NgZoneSchedulingMode not exported HOT 1
- Page Not Found HOT 1
- Functions are missing from localForage after updating Angular to latest version HOT 2
- "updateOn: 'blur'" does not work in formBuilder/formControl HOT 11
- App-shell docs are out-of-date
- https://angular.dev/guide/security not found HOT 2
- Destroy component itself HOT 5
- Image lazy loading doesn't work in SSR when using ngTemplateOutlet and disabled hydration
- @angular/compiler `parseTemplate` fn does not properly parse `HTML` string element text content containing `@` HOT 2
- Angular 17 SSR: Slow server response time when using wildcard route HOT 5
- ERROR LOADING PAGES AFTER USE router.navigate
- SSR fails when root AppComponent in index.html is self-closing HOT 1
- foo = signal(''): if string is empty, !!foo () returns false HOT 1
- Form input mask provided by the framework HOT 6
- [Feature] Introduce Type-safe Token Providing HOT 6
- docs: `inject()` is missing all overloads
- Add distinction between model() and model.required() on type level HOT 1
- Standalone Component Exports HOT 1
- Set ViewEncapsulation per module HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular.