I'm using Angular 2 here with Typescript.
I have an array of objects which looks like this;
lists: any [] = [
{title: 'Title1', content: 'Content1', id: 10},
{title: 'Title2', content: 'Content2', id: 13},
{title: 'Title3', content: 'Content3', id: 14},
{title: 'Title4', content: 'Content4', id: 16},
];
All I'm trying to do is that I need a true or false value returned after finding a particular id in the array.
I found an example with strings which is below.
myFunction() {
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var a = fruits.indexOf("Apple");
var d = a >= 0 ? true : false
console.log(d);
}
But when I apply this in my situation, it didn't work.