单击不同的广播按钮时,更改Angular $示波器值



我正在进行一个角度项目,我试图通过更改单选按钮来更改范围值和元素值。单击"单击单击"按钮1时,我将从服务器中获得值,并将其保存在范围和元素中。当我单击单击"单击"按钮2时,必须删除所有范围和元素。清空了所有范围。但是我的问题是,当我编辑输入时,单击"单击单击"按钮2,显示了两者中的跨度值和置换器。跨度不得显示。这是我的代码。

index.html

<div class="row">
    <div class="col" style="border: none;">
      <ion-item class="item-checkbox" style="border: none;">
        <label class="checkbox">
<input type="radio" id="oldChecked" ng-value="true" ng-model="oldChecked" ng-click="showName()">
            </label> Radio 1
      </ion-item>
    </div>
    <div class="col" style="border: none;">
      <ion-item class="item-checkbox" style="border: none;">
        <label class="checkbox">
                <input type="radio" id="newChecked" ng-value="true" ng-model="newChecked" ng-click="deleteName()">
            </label> Radio 2
      </ion-item>
    </div>
  </div>
   <div class="col" style="width: 100%;">
  <label class="item item-input item-floating-label" style="
  border-left:  none;border-right: none;border-top:none;">
  <span class="input-label" style="text-align: left;">Name 
  <font style="color: #ef473a;font-size: 14px;">*</font>
  </span>
  <input type="text" placeholder="Name" ng-model="pName"
   id="pName" name="pName" required>
 </label>
        </div>

Controller.js

$scope.showName=function(){
$http.post(WebServer_URL, data, config)
  .success(function (data, status, headers, config) {
    var x2js = new X2JS();
    var jsonOutput = x2js.xml_str2json(data);
    var myPatient = JSON.parse(jsonOutput.string);
    $scope.pName = myPatient[0].Pt_Name;
    document.getElementById('pName').value = myPatient[0].Pt_Name;
}).error(function (data, status, header, config) {
    console.log("Status: " + status);
  });
}
    $scope.deleteName=function(){
    $scope.pName="";
    document.getElementById('pName').value = "";
 }

这是显示跨度和占位符的图像

请在这个问题上帮助我。预先感谢。

// radio buttons should have same ng-model
<input type="radio" value="oldChecked" ng-model="myOption" ng-click="showName()">
<input type="radio" value="newChecked" ng-model="myOption" ng-click="deleteName()">
<input type="text" id="pName" ng-model="pName" placeholder="Name">
  <script type="text/javascript">
    var app=angular.module("test",[]);
    app.controller("testCtrl",function($scope){
    $scope.showName=function(){
      $scope.pName = "Hello";
    }
    $scope.deleteName=function(){
     $scope.pName="";
    }
});

最新更新