Last active
April 8, 2019 16:17
-
-
Save pranayjswl007/cb398cb04f527c2f5280c2c7ca924e41 to your computer and use it in GitHub Desktop.
Refresh Apex without any change in Database.
This file contains 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
<template> | |
<lightning-input label={realFormData.FirstName} value={realFormData.FirstName} if:true={realFormData} onchange={updateValue}></lightning-input> | |
<button class="slds-button" onclick={myRefreshFunction}> Cancle edit</button> | |
</template> |
This file contains 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 { LightningElement ,wire,track,api } from 'lwc'; | |
import myContact from "@salesforce/apex/ContactController.fetchContact"; | |
import { refreshApex } from '@salesforce/apex'; | |
export default class Myrefreshapextest extends LightningElement { | |
@api wiredContact; | |
@api realFormData; | |
@wire (myContact) | |
fetchedContacts(resp){ | |
this.wiredContact = resp; | |
this.realFormData = {... this.wiredContact.data}; | |
} | |
updateValue(event){ | |
this.realFormData = {...this.realFormData , FirstName: event.detail.value}; | |
} | |
@api | |
myRefreshFunction(event ){ | |
console.log('Refresh Apex called'); | |
refreshApex(this.wiredContact); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment