我正在使用click事件来打开这样的模态窗口,
但是在这个点击事件中,我需要传递一个id值,这样我就可以显示有关该id值的详细信息.这是控制器部分,
$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'
});
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点...... ???
谢谢.
dev*_*qon 13
您将当前范围分配给模态,因此您只需将变量分配给$scope对象:
$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();
}
Run Code Online (Sandbox Code Playgroud)
在你看来:
<ul>
<li ng-repeat="item in items"
ng-click="openModal(item.id)">
{{ item.name }}
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
然后你可以访问你的模态中的id:
<div class="modal">
<h1>{{ selectedId }}</h1>
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9870 次 |
| 最近记录: |