我正在研究angularjs和新的它,我做了一个应用程序使用this.There几个页面的应用程序,现在我的问题是我有两个按钮导航到另一个?页面,但我的问题是,当我那个按钮(跨度)点击两次打开同一个页面,任何人都可以请帮我如何解决这个我的代码如下:防止一个按钮在angularjs中被点击两次
的JavaScript
$scope.foo = function() {
if ($scope.filterflg !== "1") {
$scope.filterflg = "1";
$scope.disabled = true;
gallery.pushPage("filter.html", {
params: FkCategory
});
$timeout(function() {
console.log("====timeout occured===");
$scope.filterflg = "0";
$scope.disabled = false;
}, 3000);
}
};
html
<ons-button id="test1" class="toolbar-button--quiet navigation-bar__line-height" ng-click="isProcessing=true;foo()" ng-model ="filterflg"
style="border: none; padding: 0 5px 0 0; margin-right:7px ;">
<i class="ion-android-options" style="font-size:24px; color: #FFFFFF;"></i>
</ons-button>
我已经浪费了10天这个问题,希望有哥们帮我救我的工作..!:(
这可能会帮助你。 http://stackoverflow.com/questions/29984581/how-do-you-disable-the-submit-button-after-a-single-click-to-prevent-multiple-su –
你可以使用“ng-禁用”。只需使用示波器功能,例如 ng-disabled =“isDisabled” –
您的函数foo()调用了两次吗?你为什么使用'timer'? –