Skip to content

Instantly share code, notes, and snippets.

@britishboyindc
Created September 23, 2019 14:13
Show Gist options
  • Save britishboyindc/49c122832cf487d3ff04108941d01c69 to your computer and use it in GitHub Desktop.
Save britishboyindc/49c122832cf487d3ff04108941d01c69 to your computer and use it in GitHub Desktop.
<template>
<template if:true={opportunity}>
{myAmount}
</template>
</template>
import { LightningElement,api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
const FIELDS = ['Opportunity.Name', 'Opportunity.Amount'];
export default class DemoOptyAmount extends LightningElement {
@api recordId;
@wire(getRecord, { recordId: '$recordId', fields: FIELDS })
opportunity;
get myAmount() {
if (this.opportunity && this.opportunity.data) {
return this.opportunity.data.fields.Amount.value;
}
return 0;
}
}
<!-- Demo Opty Parent -->
<template>
<lightning-input label="parent id" onchange={handleIdChange}></lightning-input>
<c-demo-opty-amount record-id={parentid}></c-demo-opty-amount>
</template>
import { LightningElement, track } from 'lwc';
export default class DemoOptyParent extends LightningElement {
@track parentid ='';
handleIdChange (event) {
try {
let evtvar = event.target.value;
console.log(evtvar);
this.parentid = evtvar;
}
catch (err){
console.log(err);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment