簡體   English   中英

將$ scope變量值與formData AngularJS綁定

[英]Binding $scope variable value with formData angularjs

我正在嘗試提交表單。我正在使用ng-submit。單擊表中的特定用戶后,我使用firstName調用模式彈出窗口。 這是html的代碼。

    <form ng-submit="submitPunch()"  class="form" ng-show="true"> 
    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-
    hidden="true">&times;</button>
    <h4 class="modal-title" id="myModalLabel">Employee Punch In</h4>
    </div>
    <div class="modal-body">
    <div class="row">
        <div class="col-md-12 col-lg-12 form-group mgl15">
            <label for="type">Employee</label><br>
            <input type="hidden" ng-model="formData.employeeId">
            {{firstName}} /* Here i want to show only firstName but i want to pass corresponding id of the employee with formData */
        </div>
        <div class="col-md-6 col-lg-6 form-group mgl15">
            <label for="PIN">{{'label.Enter_Pin'|i18next}} <span
            class="text-red">*</span></label>
            <input class="form-control" id="pin" ng-model="formData.pin"
            type="text" required>
        </div>
       </div>
  </div>
       <div class="modal-footer">
       <button type="button" class="btn btn-default" data-
       dismiss="modal">Close</button>
       <button type="submit" class="btn btn-primary" ng-
       disabled="submitStatus==='success'">Submit</button>
       </div>
       </form>

這是我將firstName傳遞給模式的方式

Controller.js

    $scope.testpopup = function(employee){
            $scope.firstName = employee.firstName;
            $scope.employeeId=employee.id;
            console.log($scope.employeeId);//Here i am getting id
            $(".testmodal").modal("show");
        }

現在我想將員工ID和pin一起發送。但是如果我將employeeId與formData綁定是沒有用的。我想將id與pin一起傳遞以進行保存。有人可以告訴我如何將id與formData綁定嗎? scope.formData),僅顯示輸入的密碼,而不顯示員工ID。

這是我做過的小提琴。

$scope.testpopup = function(employee){
    $(".modal").modal("show");
    $scope.selectedEmployee = employee;
}

如果這與您的意圖不符,請給我反饋。

但我建議您使用uib-modal。

更新

另一個小提琴在這里。

這更符合您的目的嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM