31
loading...
This website collects cookies to deliver better user experience
ng new MyFirstProject
) and open in your fav editor (I used VS Code) you should see something like below -npm start
you will see your application running in localhost:4200 like below - import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'MyFirstProject';
}
@Component
on the top of the class. Decorator is actually a function which takes in an object as an argument. So here you can see @Component has a () that means a function call is happening and it is taking an object. This object we call as metadata. Here we can see that there are three (3) metadata present namely - selector
, templateUrl
, styleUrls
.<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>MyFirstProject</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>
'app-root'
that we came across in the @Component decorator selector metadata.india
.india
) replacing app-root what you just gave in your selector in the index.html file and let me know what happens. So it should be <india></india>
.