输入更改时检查单选按钮

时间:2014-03-22 00:26:40

标签: angularjs

Sign in image

如何在控制器中选择'是'用户开始输入密码字段时的选项按钮?

<!-- views/index.html -->

<label for="optionsRadios1">
  <input type="radio" name="optionsRadios" id="optionsRadios1" value="new" ng-model="user.type" checked>
  No, I am a <b>new customer</b>.
</label>

<label>
  <input type="radio" name="optionsRadios" id="optionsRadios2" value="old" ng-model="user.type">
  Yes, I have a password:
  <input id="password" ng-change="changeupinhere()" ng-model="password2014" type="password" name="password">
</label>

控制器

   $scope.changeupinhere = function () {
      // What do I put here?
    };

1 个答案:

答案 0 :(得分:0)

$scope.changeupinhere = function () {
  $scope.user.type = 'old';
};