0

こんにちは私はブートストラップのModalpopupに従っています。コントローラ側の角度を使用して、$scope.tagsのデータを取得します。ここでは、ng-repeat="vendor in tags"を使用してWebページにデータをバインドしたいと考えています。ブートストラップモーダル角度バインディングを使用してデータをバインドする

.HTML

<div id="myModal" class="modal fade" role="dialog"> 
<div class="modal-dialog"> 
<div class="modal-content"> 
    <div class="modal-header"> 
    <button type="button" class="close" data-dismiss="modal">&times;</button> 
    <h4 class="modal-title">Tags To Image</h4> 
    </div> 
    <div class="modal-body"> 
     <div style="padding: 20px;" ng-repeat="vendor in tags"> 
      <div class="col-md-4"> 
      <select 
       data-placeholder="Select Type" 
       class="form-control" 
       chosen 
       ng-model="vendor.type" 
       ng-options="item for item in vendorTypes"> 
      </select> 
      </div> 
      <div class="col-md-4"> 
      <select 
       data-placeholder="Select Vendor" 
       class="form-control" 
       chosen 
       ng-model="vendor.vendor" 
       ng-options="item.id as item.business.name for item in vendors"> 
      </select> 
      </div> 
      <div class="col-md-4"> 
      <a class="btn btn-primary" ng-click="item.vendors.splice(item.vendors.indexOf(vendor), 1)"> - </a> 
      </div> 
     <!-- </div> --> 
     </div> 
    </div> 
    <div class="modal-footer"> 
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
    </div> 
</div> 

私はモーダルポップアップのイベントをGET以外のボタンをクリックしてください。

$('#myModal').on('show.bs.modal', function(e) { 
     indaaix = $(e.relatedTarget).context.value; 

     $scope.tags = $scope.tags = [{ 
      type: "Event planner", 
      vendor: "cus_7VTYxJ64KZ6Iaz" 
     }]; 
     console.log($scope.tags); 
     } 
    }); 

データはウェブページにバインドされていません。私が間違っていたのは、コメントや回答を残しておいて、テストすることができます。ありがとう。

答えて

1

jQueryのイベントハンドラは、消化角度範囲をトリガしないだろう、そのハンドラの変化を知ることはできませんので、角度は、明示的にイベントハンドラで消化スコープをトリガする必要があります

$('#myModal').on('show.bs.modal', function(e) { 
    $timeout(function(){ 
     indaaix = $(e.relatedTarget).context.value; 

     $scope.tags = $scope.tags = [{ 
      type: "Event planner", 
      vendor: "cus_7VTYxJ64KZ6Iaz" 
     }]; 
    }) 

}); 

$timeoutサービスが内部

scope.$digestを呼ぶだろう
+0

ありがとうございます。私をたくさん助けて – higunjan

関連する問題