我试图搜索一个值是否在数组中退出。我使用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
它的国际化作为数组 –