How to set click event for button in onsen ui?

柔情痞子 提交于 2020-02-04 05:03:25

问题


I use phonegap and onsen in my application.

How to set click event for button in onsen ui?

Thank you.

Sorry for my poor english.


回答1:


You can use ng-click directive. Because Onsen UI is internally based on AngularJS, learning AngularJS would help you greatly.

https://angularjs.org/

page1.html

<ons-page ng-controller="yourController">
  <ons-button ng-click="foo()">Push Page 2</ons-button> 
</ons-page>

app.js

var yourApp = angular.module('myApp', ['onsen.directives']);

yourApp.controller("yourController", function($scope) {

    $scope.foo = function(){       
        alert("foo!");
    }

});


来源:https://stackoverflow.com/questions/24032225/how-to-set-click-event-for-button-in-onsen-ui

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!