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

Angular v18 support #289

Open
NrujalSharma opened this issue Jun 25, 2024 · 6 comments
Open

Angular v18 support #289

NrujalSharma opened this issue Jun 25, 2024 · 6 comments

Comments

@NrujalSharma
Copy link

Is your feature request related to a problem? Please describe.
For us relying on ngx-spinner and want to upgrade our Angular apps to Angular 18 it's not possible at the moment.

Describe the solution you'd like
ngx-spinner support for Angular 18

@NrujalSharma
Copy link
Author

@Napster2210 Any update on this?

@dahool
Copy link

dahool commented Jul 23, 2024

version 17 works just fine with Angular 18

@Napster2210
Copy link
Owner

@NrujalSharma Have you checked with ngx-spinner v17 ?

@phken91
Copy link

phken91 commented Jul 30, 2024

if you are using angular 18 + standalone component, remember to add the provideAnimations into [project].config.ts.

ps: just implement this to my angular 18 project

@alexandreomiranda
Copy link

alexandreomiranda commented Jul 30, 2024

@phken91 I'd appreciate if you could share how you did it. I couldn't make it work for a brand new angular app.
I'm on Angular 18.1.0, ngx-spinner 17.0.0

app.config.ts

export const appConfig: ApplicationConfig = {
    providers: [
        provideZoneChangeDetection({ eventCoalescing: true }),
        provideRouter(routes),
        provideAnimationsAsync(),
        importProvidersFrom(NgxSpinnerModule.forRoot({ type: 'ball-scale-multiple' }))
    ]
};

angular.json

"styles": [
    "src/styles.scss",
    "node_modules/ngx-spinner/animations/ball-scale-multiple.css"
],

app.component.ts

@Component({
    selector: 'app-root',
    standalone: true,
    imports: [RouterOutlet],
    template: `
    <ngx-spinner type="ball-scale-multiple"></ngx-spinner>
    <router-outlet />
    `,
    schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppComponent implements OnInit {
    
    spinner = inject(NgxSpinnerService);

    ngOnInit() {
        this.spinner.show();

        setTimeout(() => {
            this.spinner.hide();
        }, 5000);
    }
}

What am I missing?

@alexandreomiranda
Copy link

alexandreomiranda commented Jul 30, 2024

@phken91 I'd appreciate if you could share how you did it. I couldn't make it work for a brand new angular app. I'm on Angular 18.1.0, ngx-spinner 17.0.0

app.config.ts

export const appConfig: ApplicationConfig = {
    providers: [
        provideZoneChangeDetection({ eventCoalescing: true }),
        provideRouter(routes),
        provideAnimationsAsync(),
        importProvidersFrom(NgxSpinnerModule.forRoot({ type: 'ball-scale-multiple' }))
    ]
};

angular.json

"styles": [
    "src/styles.scss",
    "node_modules/ngx-spinner/animations/ball-scale-multiple.css"
],

app.component.ts

@Component({
    selector: 'app-root',
    standalone: true,
    imports: [RouterOutlet],
    template: `
    <ngx-spinner type="ball-scale-multiple"></ngx-spinner>
    <router-outlet />
    `,
    schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppComponent implements OnInit {
    
    spinner = inject(NgxSpinnerService);

    ngOnInit() {
        this.spinner.show();

        setTimeout(() => {
            this.spinner.hide();
        }, 5000);
    }
}

What am I missing?

I know what I am missing. It's working now:

in my app component, I just needed to import NgxSpinnerComponent
here is the correct version:

import { Component, inject, OnInit } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { NgxSpinnerService, NgxSpinnerComponent } from 'ngx-spinner';

@Component({
    selector: 'app-root',
    standalone: true,
    imports: [RouterOutlet, NgxSpinnerComponent],
    template: `
    <ngx-spinner type="ball-scale-multiple"></ngx-spinner>
    <router-outlet />
    `,
})
export class AppComponent implements OnInit {
    
    spinner = inject(NgxSpinnerService);

    ngOnInit() {
        this.spinner.show();

        setTimeout(() => {
            this.spinner.hide();
        }, 5000);
    }
}

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

5 participants