ng-model 値の参照を動的に変更したい。私は例えばそのようにこれを行うことができます:
$scope.test = {
normalStringValue1 : [],
normalStringValue2 : []
}
if($scope.status == 'A') {
$scope.values= $scope.test.normalStringValue1;
} else {
$scope.values= $scope.test.normalStringValue2;
}
<input ng-model="values" type="radio" name="xValues" ng-value="header.id | num">
これは機能しますが、私の問題は、「normalStringValue1または2が配列である場合にのみ参照の変更が機能することです!通常の文字列値が次のように見える場合:
$scope.test = {
normalStringValue1 : null,
normalStringValue2 : null
}
normalStringValue1 : 'Hello'
そして、参照が正しく変更されないような文字列のみを保存したいのはなぜですか? どうすればこれを修正できますか?