gpt4 book ai didi

javascript - ng-click 在 Ionic 应用程序中的项目内部不起作用

转载 作者:行者123 更新时间:2023-11-28 18:31:46 25 4
gpt4 key购买 nike

当在弹出的 ionic 模式中的项目内时,我无法触发 ng-click 事件。当我单击一个项目时,我看到它变成灰色,所以看起来它正在注册单击,但我有一个 console.log 语句作为我的 joinGroup 函数中的第一行,并且没有任何内容输出到控制台。

我还尝试使用 ion-list 和 ion-item 元素,但它们也不起作用。

<ion-modal-view>
<ion-header-bar class="bar bar-header bar-balanced">
<h1 class="title">Join Court</h1>
<button class="button button-clear button-primary" ng-click="modal.hide()">Done</button>
</ion-header-bar>
<ion-content class="padding">
<div class="list">
<div class="item item-icon-right" ng-repeat="group in groups" ng-click="joinGroup(group)">
<h2>{{group.name}}</h2>
<p>{{group.address}}</p>
</div>
</div>
</ion-content>
</ion-modal-view>

var joinGroup = function (group) {

console.log("Call joinGroup");

最佳答案

试试这个

<ion-modal-view>
<ion-header-bar class="bar bar-header bar-balanced">
<h1 class="title">Join Court</h1>
<button class="button button-clear button-primary" ng-click="modal.hide()">Done</button>
</ion-header-bar>
<ion-content class="padding">
<ion-list ng-repeat="group in groups" >
<ion-item ng-click="joinGroup(group)">
<h2>{{group.name}}</h2>
<p>{{group.address}}</p>
</ion-item>
</ion-list>
</ion-content>
</ion-modal-view>

在你的 Controller 中,在编写这样的函数时尝试使用 $scope

$scope.groups = [];
$scope.joinGroup = function(){

//do your stuff here
}

关于javascript - ng-click 在 Ionic 应用程序中的项目内部不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37847999/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com