Allow configuration of PrimeNG via a provider like providePrimeNgConfig()
#2678
Answered
by
cetincakiroglu
jreidgreer
asked this question in
PrimeNG
-
I'm loving v18! One thing that feels a bit unusual from how most library configurations are set in Angular is requiring configuration in a component via Proposal:I would propose a simple provider to pass in the configuration in the module: Current: @Component({
selector: "app-root",
templateUrl: "./app.component.html",
})
export class AppComponent implements OnInit {
constructor(private primengConfig: PrimeNGConfig) {}
ngOnInit() {
this.primengConfig.theme.set({ preset: Aura });
this.primengConfig.ripple.set(true);
}
} Proposed: export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideHttpClient(),
providePrimeNgConfig({
ripple: true,
theme: { preset: Aura },
}),
],
}; This makes the code more declarative, colocates application config better, and makes it more idiomatic to Angular. |
Beta Was this translation helpful? Give feedback.
Answered by
cetincakiroglu
Nov 8, 2024
Replies: 1 comment
-
Hi, Thanks for the great idea! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
cetincakiroglu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Thanks for the great idea!
primefaces/primeng#16716