Open In App

Create Project with App Module in Angular 17

When you try to create the Angular 17 application, you notice that the app.module.ts file is missing. Angular 17 introduces a significant change with Standalone configuration as the default in projects. But if you still want to work with the old folder structure then follow this article to the end.

Prerequisites

What is standalone mode?

The ability to operate an Angular application independently without requiring a server-side environment or backend services is referred to as the "standalone mode" in Angular. When Angular apps are being developed, tested, or executed in contexts where server-side rendering is not necessary, this mode is frequently utilized.

Features of Standalone Mode

Drawback of Standalone Mode

Benefits of Standalone Mode

Create Project with app.module.ts file

The solution to the issue where the .module.ts file was not created when launching a new project with Angular 17 has been found. The standalone mode is now the default in projects starting with Angular version 17. Therefore, if you start a new project without specifying anything, it will not have any modules.

Use the following command to create an application based on modules:

ng new geeks17 --no-standalone

Folder Structure

Screenshot-(214)

Folder Structure with app.module.ts file

Dependencies

"dependencies": {
"@angular/animations": "^17.2.0",
"@angular/common": "^17.2.0",
"@angular/compiler": "^17.2.0",
"@angular/core": "^17.2.0",
"@angular/forms": "^17.2.0",
"@angular/platform-browser": "^17.2.0",
"@angular/platform-browser-dynamic": "^17.2.0",
"@angular/platform-server": "^17.2.0",
"@angular/router": "^17.2.0",
"@angular/ssr": "^17.2.0",
"express": "^4.18.2",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.3"
}


Example

<!--app.component.html-->

<h1>hello geeks for geeks  {{title}}</h1>
//app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule, provideClientHydration } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        AppRoutingModule
    ],
    providers: [
        provideClientHydration()
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }
//app.component.ts

import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrl: './app.component.css'
})
export class AppComponent {
    title = 'geeks17';
}


Output

Screenshot-(297)

output

Article Tags :