NG-点击不会与离子DIV工作 [英] ng-click won't work with div in ionic

查看:152
本文介绍了NG-点击不会与离子DIV工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,正如标题所说,我有这个问题,说,我与我使用NG-秀财产功能一起设定一个范围$变量标识符中创建多个步骤的形式为了掩盖一切,但用户必须经历的步骤,一切工作正常,但后来,我意识到正在登顶上的按钮,每一个用户点击的形式继续寿形式的下一部分。换句话说,这样的:

Well, as stated by the title, I'm having this problem, say, i have a form with multiple steps that i created using the ng-show property along with a function to set a $scope variable to an identifier in order to hide everything but the steps that the user should be undergoing, all worked fine, but then, i realise the form was being summited on every user click on the buttons to continue tho the next part of the form. in other words this:

<button class="button button-block button-positive" ng-click="selectTab(2)">Continuar</button</label>

一个形式里面,做一些DIV是这样的:

inside a form, make some div like this:

<div ng-show="tab === 2"> ... data goes here ... </div>

显示和消失为用户导航,而且也提交表单,但如果我改变标签是这样的:

show up and disappear as the user navigates, but is also submitting the form, but if i change the tag like this :

<label class="item">
                    <div class="button button-block button-positive" ng-click="selectTab(2)">Continuar</div>
                </label>

它只是将不会在所有的工作,我的表格其不被对每一次点击提交,因此多数民众赞成对局势的最新情况,但它不工作要么,¿为什么会这样? ¿如何解决呢?

it just won't work at all, my form its not being submitted on every click, so thats an update on the situation, but its not working either, ¿why is this happening? ¿how can i fix it?.

在此先感谢和抱歉打​​扰你们。

Thanks in advance and sorry to bother you all.

推荐答案

确认类型=按钮申报你的按钮。如果你不这样做,它会自动假定它是类型提交。此外,如果你正在寻找只显示该div标签时=== 2,只需在指定NG-点击,不需要的功能。

Make sure to declare your button with type="button". If you don't, it automatically assumes it is type submit. Also if you are looking to only show that div when tab === 2, simply assign in ng-click, no need for a function.

在您selectTab(2)函数,你应该能够一个属性上的范围命名的标签,无论你传递到分配功能,激活NG-表演。

In your selectTab(2) function you should be able to assign a property on your scope named tab to whatever you pass into the function, activating ng-show.

$scope.selectTab = function(item) {
    $scope.tab = item;
    //Your other logic for soothe
};

是的,奇怪的是,这个标准是提交的按钮。我想,他们认为一个按钮,最终目的是要执行的操作,如提交。感谢队友。

Yes, strange that the standard is 'submit' for a button. I suppose they assume that a buttons ultimate purpose is to perform an action, like submitting. Thanks mate.

这篇关于NG-点击不会与离子DIV工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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