Tutorial to create an Angular app
Steps to install
-
Install latest nodejs from
https://nodejs.org/en/download
-
Install Angular
npm install -g @angular/cli
-
Install VS Code from
https://code.visualstudio.com/
Steps to create app
-
Download the initial app from
https://angular.io/generated/zips/first-app-lesson-00/first-app-lesson-00.zip
-
Unzip folder and rename the folder to your app name
-
Open the folder in VSCode and in terminal run
yarn install
-
To start the app
ng serve
-
open url
http://localhost:4200/
to see the output in the browser
Create the Component
-
Open Terminal and run
ng generate component home --standalone --inline-template --skip-tests
-
Add HomeComponent to your app's layout
-
Open app.component.ts in the editor.
-
In app.component.ts, import HomeComponent by adding this line to the file level imports.
import { HomeComponent } from './home/home.component';
-
In app.component.ts, in @Component, update the imports array property and add HomeComponent.
imports: [
HomeComponent,
], -
In app.component.ts, in @Component, update the template property to include the following HTML code.
<main>
<header class="brand-name">
<img class="brand-logo" src="/assets/logo.svg" alt="logo" aria-hidden="true">
</header>
<section class="content">
<app-home></app-home>
</section>
</main>