/** Angular Imports */ import { Component , OnInit } from '@angular/core' ; import { FormBuilder , FormGroup , Validators } from '@angular/forms' ; import { Router , ActivatedRoute } from '@angular/router' ; /** Custom Services */ import { SystemService } from '../../system.service' ; @ Component ( { selector : 'mifosx-create-code' , templateUrl : './create-code.component.html' , styleUrls : [ './create-code.component.scss' ] } ) export class CreateCodeComponent implements OnInit { /** Code form. */ codeForm : FormGroup ; param { FormBuilder } formBuilder param { SystemService } systemService param { ActivatedRoute } route param { Router } router constructor ( private formBuilder , private systemService , private route , private router ) { } /**
     * Creates the code form.
     */ ngOnInit ( ) { this . createCodeForm ( ) ; } /**
     * Creates the create code form.
     */ createCodeForm ( ) { this . codeForm = this . formBuilder . group ( { 'name' : [ '' , Validators . required ] } ) ; } /**
     * Submits the code form and creates a code,
     * if successful redirects to view created code.
     */ submit ( ) { this . systemService . createCode ( this . codeForm . value ) . subscribe ( ( response ) => { this . router . navigate ( [ '../' , response . resourceId ] , { relativeTo : this . route } ) ; } ) ; } }