Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs检查数组的类型_Javascript_Angularjs - Fatal编程技术网

Javascript Angularjs检查数组的类型

Javascript Angularjs检查数组的类型,javascript,angularjs,Javascript,Angularjs,我有一些数据可以是字符串或数组。所以,若它是一个字符串,我想显示它,若它是一个数组,我想显示它的长度 以下是数据的外观: 或 正在尝试检查以下数据类型: <div class="properties">{{typeof(row.contact)=="object" ? 1 : 2}}</div>//with 1 and 2 its more simplify. 尝试在控制器中定义 $scope.isArray = angular.isArray; 然后使用 {{

我有一些数据可以是字符串或数组。所以,若它是一个字符串,我想显示它,若它是一个数组,我想显示它的长度

以下是数据的外观: 或

正在尝试检查以下数据类型:

<div class="properties">{{typeof(row.contact)=="object" ? 1 : 2}}</div>//with 1 and 2 its more simplify.

尝试在控制器中定义

 $scope.isArray = angular.isArray;
然后使用

  {{isArray(value)? 1 : 2}}//result the same

@PabloMatiasGomez试图使用angular.isArray的可能重复项,但结果与我所说的相同,JavaScript中的字符串和数组在技术上是一个对象。您可能想检查它是否是
字符串的
实例
数组
@Hoyen是,但运算符typeof可能返回“String”或“object”
  {{isArray(value)? 1 : 2}}//result the same