值id传递给上点击离子态 [英] pass id value to ionic modal on click

查看:97
本文介绍了值id传递给上点击离子态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是点击事件,打开这样一个模式窗口,

I am using a click event to open a modal window like this ,

但在这个单击事件我需要传递一个ID值,这样我可以dispaly细节机智对于该值id。这是控制器部分,

But on this click event i need to pass an id value so that i can dispaly the details wit respect to that id value .this is the controller part ,

           $ionicModal.fromTemplateUrl('modal.html', function($ionicModal) {
                $scope.modal = $ionicModal;
            }, {
                // Use our scope for the scope of the modal to keep it simple
                scope: $scope,
                // The animation we want to use for the modal entrance
                animation: 'slide-in-up'
            });  

有没有办法做到这一点... ???

is there any way to do this...???

感谢。

推荐答案

您当前范围内分配给您的模式,所以你可以分配变量的 $范围对象:

You assign the current scope to your modal, so you can just assign the variable to the $scope object:

$ionicModal.fromTemplateUrl('modal.html', function($ionicModal) {
    $scope.modal = $ionicModal;
}, {
    // Use our scope for the scope of the modal to keep it simple
    scope: $scope,
    // The animation we want to use for the modal entrance
    animation: 'slide-in-up'
});

$scope.openModal = function(id) {
    $scope.selectedId = id;
    $scope.modal.show();
}

而在你的看法:

<ul>
    <li ng-repeat="item in items"
        ng-click="openModal(item.id)">
        {{ item.name }}
    </li>
</ul>

然后,您可以访问该ID在你的模式:

Then you have access to the id in your modal:

<div class="modal">
    <h1>{{ selectedId }}</h1>
</div>

这篇关于值id传递给上点击离子态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆