Skip to content

Instantly share code, notes, and snippets.

@leetheguy
Last active February 23, 2017 18:13
Show Gist options
  • Select an option

  • Save leetheguy/4e3a9fdafdc1ca34c27035a59e3dacd4 to your computer and use it in GitHub Desktop.

Select an option

Save leetheguy/4e3a9fdafdc1ca34c27035a59e3dacd4 to your computer and use it in GitHub Desktop.
illustrating getters and setters
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class SettingsService {
_pomLength: number;
_shortBreakLength: number;
_longBreakLength: number;
constructor(public http: Http) {
_pomLength = 1500;
_shortBreakLength = 300;
_longBreakLength = 1800;
}
get pomLength(): number {
return this._pomLength;
}
set pomLength(value: number) {
this._pomLength = value;
}
get shortBreakLength(): number {
return this._shortBreakLength;
}
set shortBreakLength(value: number) {
this._shortBreakLength = value;
}
get longBreakLength(): number {
return this._longBreakLength;
}
set longBreakLength(value: number) {
this._longBreakLength = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment