angularjs - How to use array include in multidimension array angular 2 -


hi array

this.testarray = [{ "office_id": "1", "officename": "sun" }, { "office_id": "2", "officename": "moon" }]; 

i want check whether officename sun there or not. tried used include
this.testarray.includes("sun") work 1 dimension array( return true). how if want use multidimension array. return false.

** this.testarray.includes("sun") work array
**

this.testarray = ["sun","moon","stars" }]; 

it return true exist. not working array one.

your array not multidimensional. can :

testarray.find(function(i){    return (i.officename === 'sun'); }); 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -