我試圖搜索一個值是否在數組中退出。我使用ui-select捕獲這些值,並且我創建函數來驗證值是否存在,並且所有的工作都很好,但是控制檯多次顯示我無法讀取未定義的屬性'indexOf'。無法讀取未定義的屬性'indexOf'
這裏用來捕獲數據
<ui-select multiple ng-model="entrevistainicialModel.personalidad"
ng-disabled="false"
search-enabled="true"
append-to-body="true"
class="form-control ">
<ui-select-match placeholder="Comportamientos">
{{$item.comportamiento}}
</ui-select-match>
<ui-select-choices repeat="multipleItem.idcomportamiento as multipleItem in datosJson[0].comportamientos | filter: $select.search">
{{multipleItem.comportamiento}}
</ui-select-choices>
</ui-select>
這裏選擇的代碼與功能
<td class="text-center"><input type="checkbox" ng-checked="check(entrevistainicialModel.personalidad, 1)" value="1"></td>
複選框代碼,並在這裏它的功能
$scope.check = function (data, n) {
if (data.indexOf(n) !== -1) {
return true;
} else {
return false;
}
}
所有的偉大工程!只有控制檯發送的indexOf
它的國際化作爲數組 –