Hello guys! I want to get value of the pressed button, but have some problems with it, can u help me?
I have tried (Get selected value button):
home.html–> <button (click)=“getColor($event)” value=“yellow”>Yellow Button
home.ts --> getColor(event){ console.log(event); }
But how i get (value=“yellow”) ???
Home.html
<ion-content padding>
<button ion-button color="dark" round (click)="getColor($event)" value="yellow">Yellow Button</button>
</ion-content>
Home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {Http} from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import {Injectable} from '@angular/core';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
static get parameters() {
return [[Http]];
}
constructor(private http: Http) {
}
getColor(event) {
console.log(event);
}
}
Thanks!