import { Component } from '@angular/core' ; import { CmdbType } from '../../models/cmdb-type' ; import { ActivatedRoute } from '@angular/router' ; import { TypeService } from '../../services/type.service' ; import { UserService } from '../../../management/services/user.service' ; @ Component ( { selector : 'cmdb-type-add' , templateUrl : './type-add.component.html' , styleUrls : [ './type-add.component.scss' ] } ) export class TypeAddComponent { public typeInstance : CmdbType ; constructor ( private route , private typeService , private userService ) { this . typeInstance = new CmdbType ( ) ; this . route . queryParams . subscribe ( ( query ) => { if ( query . copy !== undefined ) { this . typeService . getType ( query . copy ) . subscribe ( ( copyType ) => { delete copyType . public_id ; delete copyType . _id ; delete copyType . author_id ; this . typeInstance = copyType ; this . typeInstance . author_id = this . userService . getCurrentUser ( ) . public_id ; } ) ; } } ) ; } }