角度为

时间:2016-02-06 12:45:53

标签: angularjs radio-button

我正在处理有角度的单选按钮。我可以从服务器填充单选按钮值,但似乎我缺少这么小的东西来正确处理它们。

HTML>>

 <label data-ng-repeat="milestoneType in question">
      <input type="radio" name="milestoneType" data-ng-model="milestoneType.Id" data-ng-value="true" data-ng-change="getMilestoneType(milestoneType.Id)" />
           {{milestoneType.Type}}
 </label><br />

脚本代码&gt;&gt;

$scope.populateType();

$scope.populateType = function() {

  $http.get(service_url + "Project/GetMilestoneType", {
      params: {
        "Id": 0
      }
    })
    .success(function(response) {
      if (response.length < 1) {
        $('#divErrorGrid').show();

      } else {
        $('#divErrorGrid').hide();
        $scope.question = response;

      }
    })
    .error(function(data) {
      fnSuccessModal("Error in Load", "Error");
    });
}

$scope.getMilestoneType = function(milestoneType) {

  console.log(milestoneType);
  if (milestoneType== "1") {

    $scope.loadProjectMilestones();
  } else if (milestoneType== "2")

    $scope.loadCategoryMilestones();
}

服务器返回的列表:

Id  Title
2    Project
3    Category

现在,我只想在用户更改界面上的单选按钮选项时使功能正常工作。每当用户选择“Project”单选按钮时,将调用loadProjectMilestones函数,如果选择“Category”单选按钮,则将调用loadCategoryMilestones函数。基于此选择,功能将起作用。

换句话说,我只想要,如果我选择Project单选按钮,那么MilestoneType值应为2,如果我选择Category单选按钮,那么该值应为3(如上面的列表所示)。

但我无法使功能正常工作。

0 个答案:

没有答案