Skip to content

Instantly share code, notes, and snippets.

<template>
<lightning-record-form
record-id={recordId}
object-api-name="Account"
layout-type="Compact"
columns="1"
mode="readonly">
</lightning-record-form>
</template>
<template>
<div>
<a href={url} onclick={handleClick}>Account Home</a>
</div>
</template>
import { LightningElement, wire, track } from 'lwc';
import { NavigationMixin} from 'lightning/navigation';
export default class NavigationLinkExample extends NavigationMixin(LightningElement) {
@track url;
connectedCallback() {
this.accountHomePageRef = {
type: "standard__objectPage",
attributes: {
({
searchHelper : function(component, event) {
var action = component.get('c.queryContact');
action.setParams({
'searchTxt': component.get("v.searchTxt")
});
action.setCallback(this, function(response){
var state = response.getState();
console.log(' ==== ' + state);
({
Search: function(component, event, helper) {
var searchField = component.find('search');
helper.searchHelper(component, event);
},
})
<aura:component controller="searchContactController">
<aura:attribute name="result" type="List" description="list of seached contacts"/>
<aura:attribute name="searchTxt" type="String" description="use for searching contacts"/>
<div class="slds-m-around_medium">
<lightning:layout>
<lightning:layoutItem size="3" padding="around-small">
<lightning:input value="{!v.searchTxt}"
required="true"
public class searchContactController {
@auraEnabled
public static List<Contact> queryContact(String searchTxt) {
String queryStr = 'SELECT Id, Name FROM Contact WHERE NAME Like \'%' + searchTxt + '%\'';
return Database.query(queryStr);
}
}
({
initHelper : function(component, event, helper) {
helper.utilSetMarkers(component, event, helper);
},
utilSetMarkers: function(component, event, helper){
//Variables declared with the let keyword can have Block Scope.
//{ let x = 2; } x cannot be uset outside the block
var action = component.get("c.getAllTowers");
action.setCallback(this, function(response){
({
init : function(component, event, helper) {
helper.initHelper(component, event, helper);
}
})
<aura:component controller="TowerMapController" implements="force:appHostable,flexipage:availableForAllPageTypes">>
<aura:attribute name="mapMarkers" type="object" access="private"/>
<aura:attribute name="markersTitle" type="object" access="private"/>
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
<aura:if isTrue="{!!empty(v.mapMarkers)}">
<lightning:map mapMarkers="{!v.mapMarkers}" zoomLevel="10" markersTitle="{!v.markersTitle}"/>
</aura:if>
</aura:component>