You need to sign in to do that
Don't have an account?
hussain raza 12
How to add attribute to lightning web component button?
Hey so i created a lightning web component button that opens a url on VS code and then deployed it to my org. Now i wanted to make this component reusable so that if i want to change the url that the button takes me to when clicked, i would just have to click on it when editing a page and it will show properties/attributes of the component and i can change the url there rather than going back to my code on VS code and changing it manually. Any help would be appreciated.
```<!-- navTab.html -->
<template>
<lightning-button variant="brand" label={label} title={label} onclick={navigateNext}></lightning-button>
</template>```
my js code is:
```// navTab.js
import { LightningElement, api, track} from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
var object = "Account";
var action = "edit";
var record = "a03B0000002tEurIAE"
export default class Navtab extends NavigationMixin(LightningElement) {
@api tabName;
@api label;
@track label = action + " " + object;
navigateNext() {
// Opens the new Account record modal
// to create an Account.
this[NavigationMixin.Navigate]({
type: 'standard__objectPage',
attributes: {
recordId: record,
objectApiName: object,
actionName: action,
}
});
}
}```
my xml code is:
```<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="testingnew">
<apiVersion>45.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>```