How to set click event for button in onsen ui?
-
21-12-2019 - |
Domanda
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.
Soluzione
You can use ng-click directive. Because Onsen UI is internally based on AngularJS, learning AngularJS would help you greatly.
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!");
}
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow