I recently started learning angular and I believe it's a good practice to include an interface in my code. The DataFetchService
service is currently retrieving data from an internal .json
file. Can someone guide me on the best approach to implement an interface for this scenario? Any suggestions or resources would be greatly appreciated.
import { Component, OnInit } from '@angular/core';
import { DataFetchService } from '../userActions';
interface getDataInterface {
name: string;
surename: string;
}
@Component({
selector: 'app-data-from-server',
templateUrl: './data-from-server.component.html',
styleUrls: ['./data-from-server.component.css']
})
export class DataFromServerComponent implements OnInit {
users$: Object;
constructor(private data: DataFetchService) { }
ngOnInit() {
this.data.getData().subscribe(
data => this.users$ = data
)
}
}