2016-01-06 62 views
1

在Angularjs中,我想显示从ng-repeat中从模态选取的文本框中的值。我怎样才能做到这一点?如何从文本框中的angularjs模态中获取值?

+1

,你能否告诉我们到目前为止你有什么? – SjaakvBrabant

+0

如果你使用角度引导UI,你可以很容易地做到这一点,这里解释 - https://angular-ui.github.io/bootstrap/#/modal –

+0

这是不可能回答,太泛泛。我可以提供的最佳答案是:1.从模态中获取价值。 2.绑定到文本字段模型。 – dfsq

回答

0

在HTML视图:

<input ng-model="batchno_qty[$index]"> 

在控制器:

$scope.show_qty=function(item_id,index){ 
$scope.current_index=index; 
$scope.batchno_qty1=[]; 
var modalInstance = $modal.open({ 
      templateUrl: 'opportunities/show_qty_popup.php', 
     controller: pick_supplier, 
     scope: $scope, 
     resolve: {current_index: function() { 
        return $scope.current_index; 
        } 
       } 
    }); 
    modalInstance.result.then(function (response) { 
     $scope.response=response; 
     $scope.batchno_qty=[]; 
    });   
    } 

    function pick_supplier($scope, $modalInstance,current_index) 
    {  
    $scope.batch_select=[]; 
    $scope.selected_qty=[]; 
    $scope.pick_qty = function (itemid) { 
     $scope.array_qty=[]; 
     $scope.pick={}; 
     if($scope.batch_select.length==0) 
     { 
      Notification.error("No Batch no. is selected."); 
     } 
     else 
     { 
      for (var i = 0; i < $scope.batch_select.length; i++) 
      { 
       if($scope.batch_select[i]==undefined) 
       { 
        //Notification("your Batch no. is undefined."); 
       } 
       else 
       { 
        if($scope.selected_qty[i]==undefined) 
        { 
         Notification("Please enter quantity."); 
        } 
        else 
        {  
       $scope.pick[$scope.batch_select[i]] 
        =$scope.selected_qty[i]; 

        } 
       } 
      } 
     } 
        $scope.total_pick=0; 

     $scope.set=1; 
     supplier_result.itemid=itemid 
     $modalInstance.close($scope.pick); 
     } 
    } 
相关问题