I need to check if data is have a type as acc-item
, if yes then I need assign a value true
or false
to this variable hasAccordionLayout
.
data = [
{
type:"text",
text:"This is just text"
},
{
type:"acc-item",
text:"This is acc-item"
},
{
type:"acc-item",
text:"This is acc-item 2"
},
{
type:"text",
text:"This is just text"
}
];
This is what I tried, But want to do it in a better way
this.hasAccordionLayout = (this.data.filter( function(content) {
if(data.type === 'acc-item') {
return data;
}
})).length > 0? true: false;