A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/angular-js/components-in-angular-8/ below:

Components in Angular 8 - GeeksforGeeks

Components in Angular 8

Last Updated : 04 Nov, 2020

The component is the basic building block of Angular. It has a selector, template, style, and other properties, and it specifies the metadata required to process the component. 

Creating a Component in Angular 8:

To create a component in any angular application, follow the below steps:

ng g c <component_name> 
OR
ng generate component <component_name> 

Using a component in Angular 8:

Implementation code: Please note that the name of the component in the below code is gfg component.

gfg.component.html:

html

gfg.component.css:

javascript
h1{
    color: green;
    font-size: 30px;
}

gfg.component.ts:

javascript
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-gfg',
  templateUrl: './gfg.component.html',
  styleUrls: ['./gfg.component.css']
})
export class GfgComponent{
    a ="GeeksforGeeks";
}

app.module.ts:

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

import { AppComponent } from './app.component';
import { GfgComponent } from './gfg/gfg.component';
 
 
@NgModule({
  imports:      [ BrowserModule ],
  declarations: [ AppComponent, GfgComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

Output:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4