Mehul D
Mehul D

Reputation: 140

Implement Css and Js function on Custom Button in Ionic

I am Trying to Create Custom Button in Ionic.

So, My Question Is I want to Implement Both CSS Method And Controller.js Function Method To my HTML File Class Button. How to add both Methods to button??

Html File

<div>
<button class="custom_btn"> 
</button>

style.css File Code:

.custom_btn {

    width: 200px;
    height: 200px;
    padding: 10px;
    line-height: 50px;
    text-align: left;
    text-indent: 10px;
    font-family: Verdana, Geneva, sans-serif;
    font-size: 16px;
    color: #333;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    border: 1px solid #333;
    background-color: white;
    cursor: pointer;
    margin: 20px;
} 

Controller.js File Code

in Controller.js File I am performing some Action on Button When it's Tapped

$scope.btnClicked = function()
{
//Perform some Action When it's Clicked
 }

Custom Button On Screen is displaying as per CSS Code but It's not Calling Function Method.Please Provide any solution.thanks.

Upvotes: 0

Views: 583

Answers (1)

Dah Person
Dah Person

Reputation: 373

Change your button to

<button class="custom_btn" onclick="whenButtonIsClicked()"> 
</button>

And your JS code to

function whenButtonIsClicked() {
//actions to perform
}

Explanation: The onclick property of the button tells the whenButtonIsClicked() function to run when the button is clicked. A framework is not necessary for this action.

Upvotes: 1

Related Questions