I have a simple json data,I need to get the name from object by comparing its id.Suppose I have a number 2,I need to compare with object's id,if it is equal to 2 then I need to get matching object's property 'name' from object.Like here it will be matching name 'dog' in my json. Here is the code below https://stackblitz.com/edit/angular-dtyvrc?file=src%2Fapp%2Fapp.component.ts
app.component.html
<hello name="{{ name }}"></hello>
<p>
Start editing to see some magic happen :)
</p>
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular';
ngOnInit() {
let statusdata1 = [{"id":1,"name":"cat"},{"id":2,"name":"dog"}]
console.log('dog')
}
}