Created
February 10, 2018 18:16
-
-
Save Frelseren/778a95ce3152e79b1cff3c9ca5827d80 to your computer and use it in GitHub Desktop.
Angular app REST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { ApexService } from '../apex.service'; | |
interface Contact { | |
Id: string; | |
Name: string; | |
} | |
@Component({ | |
selector: 'app-contacts', | |
templateUrl: './contacts.component.html' | |
}) | |
export class ContactsComponent implements OnInit { | |
contacts: Contact[]; | |
constructor( | |
private apex: ApexService | |
) {} | |
ngOnInit() { | |
this.apex.get().subscribe( | |
contacts => this.contacts = contacts, | |
error => console.log(error) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment