2016-12-01 76 views
1

我無法綁定我的模態內的任何點擊。該模態是在我的控制器定義:Ng點擊離子模態內的綁定問題

$scope.fooBar = function() { 
    alert("FOO!"); 
}; 

$ionicModal.fromTemplateUrl('templates/modals/withdrawal.html', { 
    scope: $scope 
}).then(function(modal) { 
    $scope.cashoutModal = modal; 
}); 

$scope.lists = [ 
    { foo: "CLICK ME 1"}, 
    { foo: "CLICK ME 2"} 
]; 

模態的看法是:

<ion-header-bar align-title="center" class="bar bar-header bar-positive"> 
    <h1 class="title">Richiedi un bonifico</h1> 
    <button ng-click="fooBar()" class="button button-clear button-primary fixed-bar-pos"><i class="ion-ios-close-outline"></i></button> 
</ion-header-bar> 

<ion-content class="padding"> 
    <ion-list> 
     <ion-item ng-repeat="list in lists"> 
      <div class="weddingListItem" ng-click="fooBar()"> 
       <span class="title">{{list.foo}}</span> 
      </div> 
     </ion-item> 
    </ion-list> 
</ion-content> 

正如你可以通過點擊靜態按鈕或任何動態生成的見列出項目的功能fooBar應該觸發,而不會發生任何事情,控制檯中沒有錯誤,沒有警報。

enter image description here

,將模態工作,如預期的視圖渲染,我缺少什麼嗎?

回答

0
<ion-modal-view ng-controller="ModalController"> 
     <ion-header-bar> 
      <h1 class="title">Richiedi un bonifico</h1> 
      <button ng-click="fooBar()" class="button button-clear button-primary fixed-bar-pos"><i class="ion-ios-close-outline"></i></button> 
     </ion-header-bar> 
     <ion-content class="padding"> 
      <ion-list> 
      <ion-item ng-repeat="list in lists"> 
       <div class="weddingListItem" ng-click="fooBar()"> 
       <span class="title">{{list.foo}}</span> 
       </div> 
      </ion-item> 
      </ion-list> 
     </ion-content> 
     </ion-modal-view> 

DEMO