58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
import { LightningElement,api, wire, track } from 'lwc';
|
|
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
|
|
// import templateOne from './templateOne.html';
|
|
// import templateTwo from './templateTwo.html';
|
|
|
|
// import NAME_FIELD from '@salesforce/schema/Account.Name';
|
|
// import PHONE_FIELD from '@salesforce/schema/Account.Phone';
|
|
const FIELDS =[
|
|
'Account.Name',
|
|
'Account.Phone',
|
|
]
|
|
export default class BaiscLWCLearn extends LightningElement {
|
|
message = 'Api Example';
|
|
@api recordId;
|
|
@track ShowButton=false;
|
|
showInfo = false;
|
|
showInputFiledVal = false;
|
|
buttonLabel;
|
|
@wire(getRecord, {recordId: '$recordId',fields:FIELDS})
|
|
record; //it contain data and error
|
|
|
|
get name(){
|
|
return this.record.data.fields.Name.value;
|
|
}
|
|
|
|
get phone(){
|
|
return this.record.data.fields.Phone.value;
|
|
}
|
|
|
|
getName(event){
|
|
console.log('Name', event.target.value);
|
|
this.ShowButton=true;
|
|
}
|
|
|
|
connectedCallback(){
|
|
console.log('Connected Call Back is Called');
|
|
}
|
|
buttonClicked(event)
|
|
{
|
|
this.buttonLabel = event.currentTarget.dataset.id;
|
|
this.showInfo = true;
|
|
this.showInputFiledVal = true;
|
|
//this.template.querySelector('.input1').value = buttonLabel + ' is Clicked';
|
|
}
|
|
|
|
renderedCallback()
|
|
{
|
|
if(this.showInputFiledVal)
|
|
{
|
|
this.template.querySelector('.input1').value = this.buttonLabel + ' is Clicked';
|
|
this.showInputFiledVal = false;
|
|
}
|
|
}
|
|
|
|
disconnectedCallback(){
|
|
console.log('Disconnected Call Back is Called');
|
|
}
|
|
} |