Disable button in ionic 2

hey guys

if i have an id fro each button :
<button inline id="9" > submit </button>
and i want to compare this id into a specific number if they are equal i want to disable the button

i use ionic 2 ts


you can do it in CSS

pointer-events: none;

Add this class to perticular button id using angular 2’s [ngClass]

How are you setting these ids? Are they generated as part of an ngFor loop?

no i just putted like <button clear id="1" >something</button>

That makes things a little more tedious. Assuming you have the target id in your controller, you’ll want something like this:

class MyPage {
  // modify this property to change which button is disabled
<button id="1" [disabled]="disabledButtonId == '1'">button 1</button>
<button id="2" [disabled]="disabledButtonId == '2'">button 2</button>