import { Component , OnInit } from '@angular/core' ; import { Router } from '@angular/router' ; import { Address } from '../data/formData.model' ; import { FormDataService } from '../data/formData.service' ; @ Component ( { selector : 'mt-wizard-address' , templateUrl : './address.component.html' } ) export class AddressComponent implements OnInit { title = 'Where do you live?' ; address : Address ; form : any ; constructor ( private router , private formDataService ) { } ngOnInit ( ) { this . address = this . formDataService . getAddress ( ) ; console . log ( 'Address feature loaded!' ) ; } save ( form ) { if ( ! form . valid ) { return false ; } this . formDataService . setAddress ( this . address ) ; return true ; } goToPrevious ( form ) { if ( this . save ( form ) ) { this . router . navigate ( [ '/work' ] ) ; } } goToNext ( form ) { if ( this . save ( form ) ) { this . router . navigate ( [ '/result' ] ) ; } } }