Angular Revisited 2025

From bibbleWiki
Jump to navigation Jump to search

Introduction

Been a while since I touched Angular except for when I put my loader into WASM. So this page is just to add any changes I have found

CommonModule

The structural directives, e.g. NgFor NgIf not can be import in the component. I guessing the is because of SSR so now we do this

@Component({
  selector: 'app-chess-board',
  imports: [NgFor, NgClass, NgIf],
  templateUrl: './chess-board.component.html',
  styleUrl: './chess-board.component.css'
})
export class ChessBoardComponent {
...

Assests

These now live in the public directory. I wonder if the is something to copy them from there old haught of src.

Modules now Providers

There is no app.modules.ts anymore but I believe you can make one. The new way is to edit the app.config.ts. We don't import modules but providers which do the same job.

export const appConfig: ApplicationConfig = {
  providers: [
    provideZoneChangeDetection({ eventCoalescing: true }), 
    provideRouter(routes),
    provideHttpClient()]
};