• Skip to main content
  • Skip to primary sidebar

Web Development Archive

  • Archive
You are here: Home / Other / Nem indul az Angular 17

Nem indul az Angular 17

Az Angular 14 verziójától kezdve bevezetésre került a standalone komponensek fogalma, ami lehetővé teszi, hogy a komponensek és direktívák modulfüggetlenek legyenek. Ez a funkció azonban eltérő bootstrapelést igényel.

Az alábbiakban bemutatom, hogyan tudod a standalone komponenst bootstrapelni az @NgModule használata helyett a bootstrapApplication segítségével.

1. AppModule helyett main.ts használata

main.ts

import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';

bootstrapApplication(AppComponent)
  .catch(err => console.error(err));

2. AppComponent marad ugyanaz

app.component.ts

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

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
  standalone: true,
  imports: [],
})
export class AppComponent {
  title = 'weitz-landing-1';
}

3. Távolítsd el az AppModule-t

app.module.ts

Ez a fájl már nem szükséges, így eltávolíthatod.

4. HTML és SCSS

app.component.html

HELLO

app.component.scss

Hagyd meg a jelenlegi tartalommal.

Összefoglalás

Ezekkel a módosításokkal a standalone komponenst közvetlenül bootstrappelheted az Angular alkalmazásodban. Nincs szükség @NgModule definícióra, ehelyett a bootstrapApplication függvényt használjuk, ami az új ajánlott módszer standalone komponensek esetén.

Filed Under: Other

About Gabor Flamich

I'm a web developer and designer based in Budapest, Hungary. In recent years, I've documented hundreds of solutions I came across during development. This site is an archive for useful code snippets on WordPress, Genesis Framework and WooCommerce. If You have any questions related to WordPress development, get in touch!

Primary Sidebar

  • angular.io
© 2026 WP Flames - All Right Reserved