从$ scope中获取选择的选项后,控制台日志上出现了错误消息,如“ TypeError:(intermediate value)(intermediate value).val(...)。prop不是一个函数”。请检查我的脚本出了什么问题:
HTML模板:
<ion-view view-title="Doll List">
<ion-content class="has-header">
<div class="list">
<label class="item item-input item-select">
<div class="input-label">
Product
</div>
<select name='options2' ng-model="item.doll" ng-options="DOLLtype as DOLLtype.name for DOLLtype in dolltype track by DOLLType.id">
</select>
</label>
</div>
</ion-content>
</ion-view>
controller.js
.controller('DollCtrl', ['$scope', '$stateParams', '$location', '$http', '$window', '$q', '$localStorage', '$rootScope', '$filter', 'DOLLTYPE','$timeout', function($scope, $stateParams, $location, $http, $window, $q, $localStorage, $rootScope, $filter, DOLLTYPE, $timeout) {
$scope.item = [];
$scope.item = {
id: $stateParams.id
};
$scope.dolltype = [];
DOLLTYPE.get($scope.item.id).then(function(itemtype) {
$scope.dolltype.push({id:itemtype.id, name:itemtype.name})
$scope.item.doll = $scope.dolltype[0];
console.log($scope.item.doll);
})
DOLLTYPE.all().then(function(dolltype){
$scope.dolltype=dolltype;
console.log($scope.dolltype);
})
}}
])
我该如何解决?
注意:DOLLTYPE是用于使用cordova sqlite插件查询数据的services.js的示例名称
最佳答案
有时,当您忘记分号时,可以触发此操作。
您似乎忘了放分号:
$ scope.dolltype.push({id:itemtype.id,name:itemtype.name});
DOLLTYPE.get(...)。then(...);
和DOLLTYPE.all()。then(...);
缩小时有时会破裂
关于javascript - TypeError :(中间值)(中间值).val(…).prop不是函数( ionic ),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31096897/