HTML
<template>
<lightning-card title="Won Opportunities">
<ul>
<template if:true={responseReceived}>
<template for:each={opportunities.data} for:item="opp">
<li key={opp.id}>
<div class="slds-p-around_medium lgc-bg">
{opp.Name}
</div>
</li>
</template>
</template>
</ul>
</lightning-card>
</template>
Java Script
import { LightningElement,wire } from 'lwc';
import wonOpportunities from '@salesforce/apex/OpportunityUtility.getWonOpportunities'
export default class FetchWonOpportunities extends LightningElement {
@wire(wonOpportunities ) opportunities;
get responseReceived()
{
if(this.opportunities){
return true;
}
return false;
}
}
Apex Class
public with sharing class OpportunityUtility{
@AuraEnabled(cacheable=true)
public static List<Opportunity> getWonOpportunities(){
return [SELECT Id, Name, isWon FROM Opportunity WHERE isWon = true];
}
}
Video
Video does not exists.