문제 설명
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;
});