2015-11-30 134 views
0

我有一个单选按钮的值被选择这样的:如何一个角模型绑定到另一个NG-模型

<input type="radio" ng-model="lesson.sectionID" value="{{section.$id}}"> 

我想的是输入到另一个模型的值绑定,我试图以下:

<input type="text" ng-model="module.sectionID" ng-bind="lesson.sectionID"> 

<input type="text" ng-model="module.sectionID" ng-value="lesson.sectionID"> 

当我试图NG-值它的文字输入设置为正确的值,但ACTUA没有设置模型的值。

回答

0

你可能寻找这种解决方案

angular.module('choices', []) 
    .controller("MainCtrl", ['$scope', function($scope) { 

    $scope.color = ''; 

    $scope.colors = [ 
     "Red", 
     "Green", 
     "Blue", 
     "" 
    ]; 

    $scope.changeColor = function(){ 
     $scope.color = "Red" 
    }; 

}]); 



<html> 
<head> 
<body ng-app="choices" ng-controller="MainCtrl"> 
    <div ng-repeat="color in colors"> 
    <input type="radio" ng-model="$parent.color" ng-value="color" id="{{color}}" name="color"> 
     <label > 
     {{color || 'Other'}} 
     </label> 
     <input type="text" ng-model="$parent.color" ng-show="color==''"> 
    </div> 
    <p></p> 
    The chosen color is <strong>{{color}}</strong> 
    <p></p> 
    <button ng-click="changeColor()">Change color</button> 
</body> 
</html> 
相关问题