TypeError :(中间值)(中间值).val(...)。prop不是函数(离子)

时间:2015-06-28 06:40:40

标签: javascript angularjs cordova ionic-framework

我收到错误消息,例如“TypeError :(中间值)(中间值).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 s​​qlite插件查询数据的services.js的示例名称

1 个答案:

答案 0 :(得分:1)

有时,当您忘记分号时可以触发此操作。 你似乎忘记了分号:

$ scope.dolltype.push({id:itemtype.id,name:itemtype.name}); &lt; ---

DOLLTYPE.get(...)。then(...); &lt; ---

和DOLLTYPE.all()。然后(...); &lt; ---

当你缩小时,这有时会破裂