2016-11-08 90 views
0

我想獲取所選手機的值:「normalizedNumber」。 如果我檢查項目,然後我想要做一個選定的telefono console.log。 我無法訪問對JS選擇的項目文件如何獲取檢查項目的值

HTML

<div ng-repeat="item in contactos| orderBy:'displayName' | filter : consulta"> 
        <ion-item class="item-stable" 
           ng-click="abrirGrupo(item)" 
           ng-class="{active: isGroupShown(item)}"> 
         <i class="icon" ng-class="isGroupShown(item) ? 'ion-minus' : 'ion-plus'"></i> 
         {{::item.displayName}} 
         <label style="float:right" ng-show="muestra">elegido</label> 
        </ion-item> 
        <ion-item class="item-accordion" 
           ng-repeat="i in item.phoneNumbers" 
           ng-show="isGroupShown(item)"> 

         <ion-checkbox ng-click="cambi()" 
             ng-model="tel" 
             class="checkbox-dark" 
             ng-value=i.normalizedNumber> 
          telefono: {{::i.normalizedNumber}} 
         </ion-checkbox> 


        </ion-item> 
       </div> 

JS

$scope.cambi = function() { 
      $scope.muestra = !$scope.muestra; 
      console.log('elegido: ' + $scope.tel); 
     }; 

$scope.contactos = [{ 
       "id": "1", 
       "displayName": "Kate Bell", 
       "phoneNumbers": [{ 
        "number": "(555) 564-8583", 
        "normalizedNumber": "(555) 564-8583", 
        "type": "MOBILE" 
       }, { 
        "number": "(415) 555-3695", 
        "normalizedNumber": "(415) 555-3695", 
        "type": "OTHER" 
       }] 
      }, { 
       "id": "2", 
       "displayName": "Daniel Higgins", 
       "phoneNumbers": [{ 
        "number": "555-478-7672", 
        "normalizedNumber": "555-478-7672", 
        "type": "HOME" 
       }, { 
        "number": "(408) 555-5270", 
        "normalizedNumber": "(408) 555-5270", 
        "type": "MOBILE" 
       }, { 
        "number": "(408) 555-3514", 
        "normalizedNumber": "(408) 555-3514", 
        "type": "OTHER" 
       }] 
      }, { 
       "id": "3", 
       "displayName": "John Paul Appleseed", 
       "phoneNumbers": [{ 
        "number": "888-555-5512", 
        "normalizedNumber": "888-555-5512", 
        "type": "MOBILE" 
       }, { 
        "number": "888-555-1212", 
        "normalizedNumber": "888-555-1212", 
        "type": "HOME" 
       }] 
      }]; 
     } 
+0

什麼是你看到的錯誤與我們分享,並更清楚。所以我們可以幫助輕鬆。 – katmanco

+0

它不會顯示控制檯上的選定項目 –

回答

1

值傳遞給回調:

<ion-checkbox ng-click="cambi(i)" 

,然後更改方法以接受參數

$scope.cambi = function (telefono) { 
      $scope.muestra = !$scope.muestra; 
      console.log('elegido: ' + telefono); 
     }; 
+0

我會嘗試 –

+0

它的工作原理。謝謝@Mikkel –

相關問題