My main HTML
<div>
<block></block>
<block></block>
</div>
My Component
import {Component} from '@angular/core';
import {Observable} from 'rxjs/rx';
import {HTTP_PROVIDERS} from '@angular/http';
import {OnInit} from '@angular/core';
import {TestService} from './data.service'
@Component({
selector : 'block',
template : `
<div class="col-lg-4" style="color:blue">{{_list && _list[0].name}}</div>
`,
providers : [HTTP_PROVIDERS,TestService]
})
export class TestComponent implements OnInit{
_list : any[];
constructor(private _testDataService : TestService){}
ngOnInit(){
this._testDataService.getData()
.subscribe(list => this._list = list);
}
}
I want to reuse the component in the same page to show different data for different service calls