-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Support Input/Output spread #14545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
related to #11850 |
Don't think they are related. This is a much more complex feature. |
@laco0416 yup not much related. That issue asks for |
@fabiobiondi @manuel-di-iorio sorry guys, but don't spam the thread with "+1", use reactions instead. |
Sorry otodockal I was on mobile phone and it didn't support reactions. Now fixed 8000 . Thanx |
any updates on this? It's really verbose when you want to wrap some components. for example, if you want to use mat-select from @angular/material but apply some additional styles on it to make it another component(logically). It's not ideal to add a directive on it because:
Higher Order Components solves this problem quite well. I cannot figure out another way to do the same thing without write all the Input on the wrapper again. When dealing with Output, it's even verbose because you have to introduce EventEmitter for each Output again. |
any chance we'll see this anytime? |
I like spead props! In React is possible!! |
like this? <my-component [prop1]="prop1" [...otherInputs] (...otherOutputs) ></my-component> or maybe <my-component [prop1]="prop1" [...]="otherInputs" (...)="otherOutputs" ></my-component> |
@shybaLen What such a syntax means concretely on the |
This is being tracked in the aggregate issue of #43485 for which we need to create a project proposal. |
hi, I created a possible one just for this case, I named it ngAttribute, it is a directive that receives all the input that must be included in the host, it has the same logic as the host in the directive/component decorator stackblitz: https://stackblitz.com/edit/angular-ivy-mvhptb?file=src%2Fapp%2Fdirectives%2Fng_attribute.ts |
Maybe a new directive and decorator could be implemented: <my-component [prop1]="prop1" [ngProp]="otherInputs" [ngOn]="otherOutputs"></my-component> HTML ( <input [prop1]="prop1" [ngProp]="otherInputs" [ngOn]="otherOutputs"> Component ( //...
class MyComponent {
@SpreadInputs() otherInputs: Record<string, any>
@SpreadOutputs() otherOutputs: Record<string, EventEmitter<any>> = {}
} |
@IRod22 this directives already exists for inputs and outputs for dynamic components in ng-dynamic-component, the thing is it is currently only applicable to a dynamically rendered component and not statically rendered one but it should be quite easy to add support to a static components too. |
@gund that is a good idea, but I think the community would want built-in decorators/directives instead of having verbose syntax and extra We may need an RFC or at least a poll for this as it is a potential breaking change. |
Related: #41993 |
Hello all, Do we have a workaround at the moment? |
I'm waiting for this feature |
I believe this feature made react what is today. Because it's so easy to extend and build upon something. Just compare number of component libraries in react compared to other frameworks. We people are lazy, don't wanna type every single input to extend a component. This feature is of strategic importance for the benefit of angular ecosystem. |
There is also a new library called Zag, which takes a novel approach to building UI components using FSMs(Finite State Machines) and heavily leverages spreads. |
@otodockal how come there is no svelte version of zagjs? does svelte makes it hard to implement? |
@tombohub They gave it a try, but it was removed for some reason chakra-ui/zag@bdb1950 |
Given this new feature, I was thinking, what if Angular had abstract directives that implement interfaces for native elements?
I created a complete example using a directive I created a while ago, which binds attributes: |
Any update on this ? :) |
Also wondering about this - any updates? It would really help when creating wrapper components around third party components for instance. So that when the third party updates their components we doesn't have to explicitly add or change the params in our wrapper to support them. |
hi, i was also wondering if this feature is still unplanned... |
need it |
any update on this feature |
I'm submitting a ... (check one with "x")
Current behavior
Currently each Input or Output must be explicitly declared in the component to allow its usage.
Expected behavior
I'd like to have any way to pass Inputs/Outputs to a component in the template without declaring them first. This is allowed in React with props spread and allows techniques like Higher Order Components.
What is the motivation / use case for changing the behavior?
Declaring each Input/Output is a problem when wrapping some component to extend its behaviour or to hide the component when dealing with an external library. It requires mapping each of the wrapped component Inputs/Outputs and it's very tedious and error prone. Besides any change in the wrapped component API would require touching the wrapper component.
The text was updated successfully, but these errors were encountered: