import {Page, NavController} from ‘ionic-angular’;
import {WorkoutService} from ‘…/…/services/workout.service’;
import {WorkoutsPage} from ‘…/workouts/workouts’;
@Page({
templateUrl: ‘build/pages/add-workouts/add-workouts.html’,
providers: [WorkoutService]
})
export class AddWorkout {
static get parameters(){
return [[NavController], [WorkoutService]];
}
public title;
public note;
public type;
public _workoutService: WorkoutService;
public _workouts;
public nav;
constructor(nav, WorkoutService){
this._workoutService = WorkoutService;
this.title;
this.note;
this.type;
}
onSubmit(){
var workout = {
title: this.title,
note: this.note,
type: this.type
}
// Add Workout
this._workoutService.addWorkout(workout).subscribe(workouts => {
this._workouts = workouts
},
err => console.log(err),
() => console.log('Workout Added'));
this.nav.setRoot(WorkoutsPage);
}
}