Skip to content

Instantly share code, notes, and snippets.

@leetheguy
Last active March 12, 2018 16:13
Show Gist options
  • Select an option

  • Save leetheguy/7f95b3ab02e1d1ddb88cbd03a8629034 to your computer and use it in GitHub Desktop.

Select an option

Save leetheguy/7f95b3ab02e1d1ddb88cbd03a8629034 to your computer and use it in GitHub Desktop.
illustrating getters and setters
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
@Component({
selector: 'page-settings',
templateUrl: 'settings.html'
})
export class SettingsPage {
_pomLength: number;
_shortBreakLength: number;
_longBreakLength: number;
constructor(public navCtrl: NavController, public navParams: NavParams) {
_pomLength = 1500;
_shortBreakLength = 300;
_longBreakLength = 1800;
}
get pomLength(): number {
return this._pomLength / 60;
}
set pomLength(value: number) {
this._pomLength = value * 60;
}
get shortBreakLength(): number {
return this._shortBreakLength / 60;
}
set shortBreakLength(value: number) {
this._shortBreakLength = value * 60;
}
get longBreakLength(): number {
return this._longBreakLength / 60;
}
set longBreakLength(value: number) {
this._longBreakLength = value * 60;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment