Created
June 27, 2017 13:51
-
-
Save iamsonal/495320093ed01b9b63117a2394d79153 to your computer and use it in GitHub Desktop.
DynamicComponentController.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
createComponent : function(component, event, helper) { | |
var index = component.get("v.index"); | |
$A.createComponent( | |
"ui:Button", | |
{ | |
"label":"Button " + index, | |
"press":component.getReference("c.show") | |
}, | |
function(button) { | |
var body = component.get("v.body"); | |
body.push(button); | |
console.log(body); | |
component.set("v.body", body); | |
} | |
); | |
index++; | |
component.set("v.index", index); | |
}, | |
removeComponent : function(component, event, helper) { | |
component.set("v.body", []); | |
component.set("v.index", 1); | |
}, | |
show : function(component, event, helper) { | |
var buttonLabel = event.getSource().get("v.label"); | |
component.set("v.buttonLabel", buttonLabel); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment