Angular: 2필드 데이터 바인딩 문제 (Angular: issue with two-field data binding)


문제 설명

Angular: 2필드 데이터 바인딩 문제 (Angular: issue with two‑field data binding)

내 이온 앱에 이 라디오 버튼이 있습니다.

<ion‑radio ng‑model="data.sort" ng‑value="['‑timestamp','model']" ng‑click="closeSortPopover();">Recent model (default)</ion‑radio>

$scope.data.sort['로 설정하면 자체적으로 확인하지 않습니다. ‑timestamp','model'] 컨트롤러 또는 보기의 다른 위치

codePen 여기


참조 솔루션

방법 1:

if i wrap your array to a scope variable it works just fine

html

<ion‑nav‑view>
     <ion‑view>
       <ion‑content>

          <ion‑radio ng‑model="data.sort" ng‑value="someValue" ng‑click="closeSortPopover();">['‑timestamp','model']</ion‑radio>
          <ion‑radio ng‑model="data.sort" ng‑value="'brand'"   ng‑click="closeSortPopover()">Brand</ion‑radio>

         <br/><br/>

         <button id="resetbutton" class="button icon‑left ion‑ios‑reload button‑dark" ng‑click='data.sort=someValue;'>Set to data.sort to ['‑timestamp','model']</button>

         <br/><br/>

         data.sort = {{data.sort}}
       </ion‑content>
     </ion‑view>  
</ion‑nav‑view>

controller

angular.module('ionicApp', ['ionic'])

.controller('MyCtrl', function($scope) {
  $scope.myTitle = 'This header hides the content below';
  $scope.someValue = ["‑timestamp","model"];
  $scope.data={};
  $scope.data.sort = $scope.someValue;
});

(by LouisMat.)

참조 문서

  1. Angular: issue with two‑field data binding (CC BY‑SA 2.5/3.0/4.0)

#ionic #angularjs






관련 질문

Cordova - OS 업그레이드 후 iOS/Android 모두에서 앱 충돌 (Cordova - app crashes on both iOS/Android after an OS upgrade)

모바일용 HTML 5의 특정 영역에 링크가 있는 이미지 (Image with links in certain areas in HTML 5 for mobile)

Play 스토어에서 오류 발생 - "이 앱은 모든 기기와 호환되지 않습니다." (Getting error from play store - “This app is incompatible with all of your devices.”)

div의 오른쪽 하단에 이온 버튼 정렬 (Align an ionic button at the bottom right of a div)

새로운 Xcode 프로비저닝 정책 및 Ionic Framework (New Xcode provisioning policy and Ionic Framework)

각도 [$injector:unpr] 알 수 없는 공급자 오류를 해결하는 방법? (How to solve angular [$injector:unpr] Unknown provider error?)

ionic, 팝오버 범위에 범위 변수 전달 (ionic, pass scope variable to popover scope)

Angular: 2필드 데이터 바인딩 문제 (Angular: issue with two-field data binding)

ionic 2에서 ion-title의 글꼴 색상 변경 (Change font color of ion-title in ionic 2)

PhoneGap 빌드가 내 모든 파일을 업데이트하지 않습니다. (PhoneGap build is not updating all of my files)

Ionic 빌드 Android를 수행하는 동안 오류가 발생했습니다. (Error while doing Ionic build android)

$ionicHistory.backView() stateParams 변경 후 돌아가기 (Going back after changing stateParams of $ionicHistory.backView())







코멘트