Created
February 10, 2018 18:09
-
-
Save Frelseren/ba6f30954e17ba4c3ef5e25dad229a58 to your computer and use it in GitHub Desktop.
Angular app Remote Action example
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'; | |
declare const Visualforce; | |
interface Contact { | |
Id: string; | |
Name: string; | |
} | |
@Component({ | |
selector: 'app-contacts', | |
templateUrl: './contacts.component.html' | |
}) | |
export class ContactsComponent implements OnInit { | |
contacts: Contact[]; | |
ngOnInit() { | |
Visualforce.remoting.Manager.invokeAction( | |
'AngularPOC.getContacts', | |
(result: Contact[], event) => { | |
if (event.status) { | |
this.contacts = result; | |
} else { | |
console.error(event.message); | |
} | |
}, | |
{ escape: false } | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment