离子模态中的NgClick绑定问题

时间:2016-12-01 10:25:02

标签: angularjs ionic-framework

我无法绑定我的模态中的任何点击。模态在我的控制器中定义:

User-Agent

模态视图是:

$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"}
];

正如您所见,通过单击静态按钮或任何动态生成的列表项,函数 fooBar 应该触发,而不会发生任何事情,控制台中没有错误,没有警报。

enter image description here

模态正在运行,视图按预期呈现,我在这里缺少什么?

1 个答案:

答案 0 :(得分: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