I'm studying the structure of an angular project. I saw that the index.html file is the only html code that is displayed on the page. How do I view the code related to other html pages? I thought about importing the selector for the file I want to include in the index.html file but it doesn't work for me. I tried to create this exercise that iterates through an array and checks if the first person is called Andrea. If yes, set background color to red. But nothing is displayed on the screen. That is what I wonder all the tags related to the selectors of all the components should be imported into the index.html file?
import { Component } from '@angular/core';
@Component({
selector: 'app-esercizi',
templateUrl: './esercizi.component.html',
styleUrls: ['./esercizi.component.scss']
})
export class EserciziComponent {
studente: any;
}
//ESERCIZIO 2
let studente: { id: number, name: string} [] = [
{"id": 0, "name": "Andrea"},
{"id": 1, "name": "Nicola"},
{"id": 2, "name": "Sabrina"}
]
.red-background {
background-color: red;
}
<body [ngClass]="{'red-background': studente.name=='Andrea'}">
<div *ngFor="let s of studente">
<div>{{studente.name}}</div>
<body>
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Esercizi</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>
<app-esercizi></app-esercizi>
</body>
</html>