Skip to content
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

Add provider to support Angular Standalone components #27

Open
duluca opened this issue Aug 28, 2023 · 5 comments
Open

Add provider to support Angular Standalone components #27

duluca opened this issue Aug 28, 2023 · 5 comments

Comments

@duluca
Copy link

duluca commented Aug 28, 2023

Feature Request

What is the desired behavior?

In bootstrapApplication be able to provide FlexLayoutModule members, so the entire application can have access to the directives:

import { provideFlexLayout } from '@ngbracket/ngx-layout'

export const appConfig: ApplicationConfig = {
  providers: [
    ...
    provideFlexLayout()
  ]
}

What is the use case or motivation for the desired behaviour?

Currently, if you convert an Angular app to a standalone app, which is the recommended way of creating Angular apps by the Angular team, the developer needs to import FlexLayoutModule for every individual component. Needless to say, this is tedious and creates a frustrating situation where fx-layout directives may seem to be broken at random, when the module is missing from that component. An easy mistake to make.

Sample app where I ran into this exact issue: https://github.com/duluca/local-weather-app

Is there anything else we should know?

I haven't looked into what it takes to implement a provider like this, so I'm unsure of feasibility of this request.

@DuncanFaulkner
Copy link
Contributor

This would make sense to create a provider for the layout module, again not sure myself but I will look into it.

Thanks for the suggestion.

@duluca
Copy link
Author

duluca commented Aug 29, 2023

When I was looking at https://github.com/ngbracket/ngx-layout/blob/main/projects/libs/flex-layout/module.ts and saw ModuleWithProviders<FlexLayoutModule> , I got excited to see if using importProvidersFrom(FlexLayoutModule) would work. I tested it on my sample project. No luck.

@sourav-bhar
Copy link

When I was looking at https://github.com/ngbracket/ngx-layout/blob/main/projects/libs/flex-layout/module.ts and saw ModuleWithProviders<FlexLayoutModule> , I got excited to see if using importProvidersFrom(FlexLayoutModule) would work. I tested it on my sample project. No luck.

Does importProvidersFrom(FlexLayoutModule.withConfig(configOptions, breakpoints)) work when working with standalone apps? Then inside a standalone component, one could import FlexModule / ExtendedModule / GridModule or simply FlexLayoutModule to import the required directives depending on what is used.

@DuncanFaulkner
Copy link
Contributor

@sourav-bhar
Not at the moment, but this is something that I plan to investigate soon

@DuncanFaulkner
Copy link
Contributor

@duluca @sourav-bhar: I've migrated both the demo apps to be standalone - which seems to work, I was looking to convert the library but there are a couple of issues with that will require more thought and investigation, but thought I would let you it seems to be working (though the demo apps are not the most comprehensive of applications).

the changes are all in the migrate-standalone branch - this branch is now running the latest versions of everything as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants