No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
Namespace Usage Examples and Reference
This topic provides examples of referencing components, objects, fields, and so on in
Lightning components
code.
Examples are provided for the following.
- Components, events, and interfaces in your organization
- Custom objects in your organization
- Custom fields on standard and custom objects in your organization
- Server-side Apex controllers in your organization
- Dynamic creation of components in JavaScript and Apex
Organizations with No Namespace Prefix Set
The following illustrates references to elements in your organization when your organization doesn’t have a namespace prefix set. References use the default namespace, c, where necessary.
Organizations with a Namespace Prefix
The following illustrates references to elements in your organization when your organization has set a namespace prefix. References use an example namespace yournamespace.
| Referenced Item | Example |
|---|---|
| Component used in markup | <yournamespace:myComponent /> |
| Component used in a system attribute | <aura:component
extends="yournamespace:myComponent"> <aura:component implements="yournamespace:myInterface"> |
| Apex controller | <aura:component controller="yournamespace.ExpenseController"> |
| Custom object in attribute data type | <aura:attribute name="expenses" type="yournamespace.Expense__c[]" /> |
| Custom object or custom field in attribute defaults |
|
| Custom field in an expression | <ui:inputNumber value="{!v.newExpense.yournamespace__Amount__c}" label=… /> |
| Custom field in a JavaScript function |
|
| Component created dynamically in a JavaScript function |
|
| Interface comparison in a JavaScript function | aCmp.isInstanceOf("yournamespace:myInterface") |
| Event registration | <aura:registerEvent type="yournamespace:updateExpenseItem" name=… /> |
| Event handler | <aura:handler event="yournamespace:updateExpenseItem" action=… /> |
| Application event in a JavaScript function | var updateEvent = $A.get("e.yournamespace:updateExpenseItem"); |
| Component created dynamically in Apex | Cmp.yournamespace.expenseList expList = new Cmp.yournamespace.expenseList(); |