From component
import { Component, OnInit, ViewChild} from '@angular/core';_x000D_
import { HttpClient } from '@angular/common/http';_x000D_
import { dataService } from "src/app/service/data.service";_x000D_
@Component( {_x000D_
selector: 'app-sideWidget',_x000D_
templateUrl: './sideWidget.html',_x000D_
styleUrls: ['./linked-widget.component.css']_x000D_
} )_x000D_
export class sideWidget{_x000D_
TableColumnNames: object[];_x000D_
SelectedtableName: string = "patient";_x000D_
constructor( private LWTableColumnNames: dataService ) { _x000D_
_x000D_
}_x000D_
_x000D_
ngOnInit() {_x000D_
this.http.post( 'getColumns', this.SelectedtableName )_x000D_
.subscribe(_x000D_
( data: object[] ) => {_x000D_
this.TableColumnNames = data;_x000D_
this.LWTableColumnNames.refLWTableColumnNames = this.TableColumnNames; //this line of code will pass the value through data service_x000D_
} );_x000D_
_x000D_
} _x000D_
}
_x000D_
DataService
import { Injectable } from '@angular/core';_x000D_
import { BehaviorSubject, Observable } from 'rxjs';_x000D_
_x000D_
@Injectable()_x000D_
export class dataService {_x000D_
refLWTableColumnNames: object;//creating an object for the data_x000D_
}
_x000D_
To Component
import { Component, OnInit } from '@angular/core';_x000D_
import { dataService } from "src/app/service/data.service";_x000D_
_x000D_
@Component( {_x000D_
selector: 'app-linked-widget',_x000D_
templateUrl: './linked-widget.component.html',_x000D_
styleUrls: ['./linked-widget.component.css']_x000D_
} )_x000D_
export class LinkedWidgetComponent implements OnInit {_x000D_
_x000D_
constructor(private LWTableColumnNames: dataService) { }_x000D_
_x000D_
ngOnInit() {_x000D_
console.log(this.LWTableColumnNames.refLWTableColumnNames);_x000D_
}_x000D_
createTable(){_x000D_
console.log(this.LWTableColumnNames.refLWTableColumnNames);// calling the object from another component_x000D_
}_x000D_
_x000D_
}
_x000D_