How can i extract specific data from the array with the id and use it in the div.
home.component.ts file
import { Component } from '@angular/core';
import { HomeProjectComponent } from './home-project.component';
import { NewsletterComponent } from './../shared/newsletter/newsletter.component';
export class Project {
id: number;
name: string;
title: string;
status: string;
}
const PROJECTS: Project[] = [
{ id: 1,
name: 'name1',
title: 'title1',
status: 'status1'
},
{ id: 2,
name: 'name2',
title: 'title2',
status: 'status2'
},
{ id: 3,
name: 'name3',
title: 'title3',
status: 'status3'
},
....
{ id: 100,
name: 'name100',
title: 'title100',
status: 'status100'
},
];
@Component({
selector: 'home',
templateUrl: './app/home/home.component.html',
styleUrls: ['./app/home/home.component.css'],
directives: [HomeProjectComponent, NewsletterComponent]
})
export class HomeComponent {
projects = PROJECTS;
}
This is my html code were i m trying to get the name, title and status of the project with ID home.component.html
The {{project.name}}, {{project.title}} and {{project.status}} must be the same
get data with id 20
<home>
<h1>{{project.name}}</h1>
<h2>{{project.title}}</h2>
<p>{{project.status}}</p>
</home>
// SOME HTML
get data with id 64
<home>
<h1>{{project.name}}</h1>
<h2>{{project.title}}</h2>
<p>{{project.status}}</p>
</home>
// SOME HTML
get data with id 69
<home>
<h1>{{project.name}}</h1>
<h2>{{project.title}}</h2>
<p>{{project.status}}</p>
</home>
@Component({ selector: 'home', templateUrl: './app/home/home.component.html', styleUrls: ['./app/home/home.component.css'], directives: [HomeProjectComponent, NewsletterComponent] })