Last active
March 12, 2018 16:13
-
-
Save leetheguy/7f95b3ab02e1d1ddb88cbd03a8629034 to your computer and use it in GitHub Desktop.
illustrating getters and setters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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