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
bug(all): directives are not standalone #26036
Comments
It's a work in progress I think. Maybe it might be an idea to clearly state in the docs which components are already |
I agree with @maartentibau about a list and hopefully a roadmap for the standalone directives. |
Hi, this is something that's on our radar but we still haven't been able to fully plan out. It's definitely something on the horizon, though |
@wagnermaciel if you're inviting external contributions for the standalone migration work, I'd be up for helping with it. |
Hey @michaelfaith - this work is pending some team discussion about our strategy for providing components that have a lot of dependencies. Previously, these would all be bundled in the NgModule, but as standalone we need to decide how users should consume them. This is something we want to do, but likely after v17 |
If you would fix angular/angular#48089, you could just export read-only array like the documentation suggests. |
What I'm expecting is to use a few directives (cdkTrapFocus) has composition: https://angular.io/guide/directive-composition-api#adding-directives-to-a-component I advise starting with the incremental adoption of "standalone" only for cdk directives with few dependencies (the same approach we are taking here on our private component library). My two cents. |
If you are unable/unwilling to merge angular/angular#48106 for whatever reason (some fragile internal tests failing nobody wants to touch?) then the only other option is to use NgModule: const COMPONENTS = [MyStandaloneDirective, MyStandaloneComponent];
@NgModule({
imports: COMPONENTS,
exports: COMPONENTS
})
export class StandaloneComponentModule {} |
Ok @hakimio but the main issue here is: https://angular.io/guide/directive-composition-api#adding-directives-to-a-component Specially: Directives used in hostDirectives must be standalone: true. |
Yes, I know that you can't use non-standalone directives as host-directives, my comment was meant for @andrewseguin |
@andrewseguin Sounds good. At the point where you're ready to move on it, if you're inviting contributions, I'd be up for helping. |
Without this, every user of my reusable suffix component has to remember to put that on the element. Not that bad but it would be nice to "DRY" that out... |
|
Please answer me why custom standalone directives can't import modules ? I need to show MyModalComponent. But it has it's own MyModalModule where I import material components. If I try to show MyModalComponent from my directive as it is it will throw me a bunch of errors e.g mat-icon is not defined, because my directive doesn't know anything about MyModalModule... i don't understand this, angular team just make feature and don't describe how should we use their standalone directives without ability to import things we need. When I asked this question here my ticked was closed after 15 minutes, I tried to reproduce my issue, but due to peculiarities of angular providers angular team considered that I'm an idiot who makes simple errors and didn't help me |
If MyModalComponent isn't standalone too, then you should be importing MyModalModule into your directive's imports, rather than MyModalComponent. |
The problem is that Directives doesn't have imports. I understand that If i want to show standalone component it's ok, but if my component is not standalone i wouldn't be able to show it in modal from my Directive. because i need to import module with it somewhere, or i will have to import MyModalModule in every component that defined hostDirectives with my directive, which shows my modal |
Right, sorry. Brain hasn't gotten up to full speed yet. |
CDK & Material were ported to standalone by #28155. |
Is this a regression?
The previous version in which this bug was not present was
No response
Description
As the standalone APIs have become stable in v15, I expected
@angular/material
directives to be declared as standalone, but it did not happen for some reason?Reproduction
Expected Behavior
MatTooltip and MatLegacyTooltip should be standalone directives
Actual Behavior
Error: NG0308: Host directive MatTooltip must be standalone.
Environment
The text was updated successfully, but these errors were encountered: