AngularJs Inline Check if an array check

Adam picture Adam · Aug 20, 2014 · Viewed 24.5k times · Source

Inline in AngularJs is there a way to check if something is an array?

I would have thought this to work:

<div ng-show="Array.isArray(textStuff[0][1])">Hi</div>

I have verified it is in fact an array. Is there something I am missing or another way?

Answer

Anthony Chu picture Anthony Chu · Aug 20, 2014

You can put angular.isArray on the scope...

$scope.isArray = angular.isArray;

<div ng-show="isArray(textStuff[0][1])">Hi</div>

Fiddle