Simple Button Commands


#1

Hello!

So I have a VERY basic understanding of HTML and JS but im in a class currently that kinda just throws us into projects.

When making an app with JQuery I could simple include onclick=“function ()” inside a button (in HTML) and it would call that function from my JS.

Is it that simple in ionic? I cant seem to get that to work.

Sorry for the SUPER basic question, and thanks in advance

Edit: Appologies, ive figured it out! Angular simply requires some extra steps it seems!


#2

You need to define a function in your controller like this:
$scope.sayHello = function() { console.log("Hello world"); }

Then call it from your HTML like this:
<button ng-click="sayHello()">Hello</button>