我正在研究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'? –