🔧 ProgrammierungBolt.new launches Forge to widen who gets to build with AI(17.09.2026 um 22:12 Uhr)
🔧 ProgrammierungGlobal Workspace Theory The J-Space of Claude(17.09.2026 um 22:12 Uhr)
🔧 AI Nachrichten I let a local 27B LLM audit and fix my Splunk + Sysmon stack(17.09.2026 um 22:15 Uhr)
🔧 ProgrammierungHow to Run Docker/Containers With Termux(17.09.2026 um 22:20 Uhr)
🔧 ProgrammierungI Accidentally Built a Dark Software Factory. Here's How.(17.09.2026 um 22:21 Uhr)
🔧 ProgrammierungCongrats to the DEV Weekend Challenge: Dog Days Edition Winners!(17.09.2026 um 22:22 Uhr)
🔧 ProgrammierungBolt.new launches Forge to widen who gets to build with AI(17.09.2026 um 22:12 Uhr)
🔧 ProgrammierungGlobal Workspace Theory The J-Space of Claude(17.09.2026 um 22:12 Uhr)
🔧 AI Nachrichten I let a local 27B LLM audit and fix my Splunk + Sysmon stack(17.09.2026 um 22:15 Uhr)
🔧 ProgrammierungHow to Run Docker/Containers With Termux(17.09.2026 um 22:20 Uhr)
🔧 ProgrammierungI Accidentally Built a Dark Software Factory. Here's How.(17.09.2026 um 22:21 Uhr)
🔧 ProgrammierungCongrats to the DEV Weekend Challenge: Dog Days Edition Winners!(17.09.2026 um 22:22 Uhr)
🔧 Programmierung 🕛 vor 1 Jahr 2 Min Lesezeit
0

Yet Another Angular Article, Part 2 : components creation

↗ Quelle (dev.to)
🗣️ Stimme:

, i just talked about project creation. I mean, the main project, not sub-projects. Those one will be the subject of a future article.



Today is related to component creation. And like project creation, the Angular CLI is your best friend. So go an with :



 

ng generate component hello-world



It run the code generation in the folder my-new-project/src/app/hello-world with 4 files :




  • hello-world.component.html : the template

  • hello-world.component.scss : the styles, in scss format since this is my choice at the project creation prompt

  • hello-world.component.spec.ts : the test file

  • hello-world.component.ts : the component



Now run ng serve and open the browser to localhost:4200 to see the result

Hey, but the component is not rendered ! Why ?

Because we didn't use it :-)



Now open the root component 'app.component.ts' and add HelloWorlComponent in 'imports' section :




CODE
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { HelloWorldComponent } from './hello-world/hello-world.component';
@Component({
 selector: 'app-root',
 imports: [RouterOutlet, HelloWorldComponent],
 templateUrl: './app.component.html',
 styleUrl: './app.component.scss',
})
export class AppComponent {
 title = 'angular-tutorial';
}






The component is now available in AppComponent, and we can use it. Just edit the hello-world.component.html file and replace all the code by this :




CODE
<app-hello-world></app-hello-world>
<router-outlet />






Forget router-outlet for instance since we didn't prevent the installation of Angular Router on project creation (if you don't want routing you can do this : ng new my-new-project --routing=false )



The default selector prefix is 'app', that's why the selector of the component is 'app-hello-world'



Check the browser and you will see the default content of your component.



You can customize the css by adding this to hello-world.component.scss :




CODE
:host {
 color: blueviolet
}






Check the browser and you will see the new color of the text. The :host selector is related to the current hello-world component.



So now, you know how to generate a simple component



Have a nice day 🌞



[original post] https://rebolon.medium.com/yet-another-angular-article-part-2-components-creation-550c14b991a2

Vollständiger Original-Artikel
Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Bolt.new launches Forge to widen who gets to build with AI
1 Quelle
Common Pitfalls in RAG Applications: What to Avoid When Using Vector Search and Embeddings
1 Quelle
Turn Your Android Phone Into a Local Development Server With Termux
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Yet Another Angular Article, Part 2 : components creation

Thematisch verwandte Begriffe: Another, Angular, Article, Part · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...