簡體   English   中英

AngularJS檢查typeof數組

[英]Angularjs checking typeof array

我有一些可以是字符串或數組的數據。 因此,如果它是一個字符串,我想顯示它,如果它是一個數組,我想顯示它的長度。

數據如下所示: 在此處輸入圖片說明 要么 在此處輸入圖片說明

嘗試檢查以下數據類型:

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

但在兩種情況下,它都將顯示2 為什么會這樣,我該如何解決?

PS

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

嘗試在控制器中定義

 $scope.isArray = angular.isArray;

然后使用

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM