Why won't my Lightning Component Attributes store entered value
This issue is currently scheduled to be fixed in the Summer '17 release by leveraging Proxy as Doug mentioned in the comments to another answer. I've verified the fix with a very similar scenario on the Summer '17 codeline. Unfortunately, the fix is not scheduled to be patched in to Spring '17 as initially hoped for.
Code is working as expected.
In the above approach there is basic problem. Lightning does not initialize any variable itself.
In controller testString
is not defined so, it is not even getting set and result {}
:-
public class myProblemClass {
@AuraEnabled public string myTestString {get;set;}
public myProblemClass(){
}
public myProblemClass(String setDefault){
mytestString = setDefault;
}
}
Define variable in no argument constructor and it will start working:-
public myProblemClass(){
mytestString = '';
}
There is a framework logic. Only you know there is myCustomClass.myTestString but framework doesn't know.
Take the example: set the input as:
<ui:inputText aura:id="firstInput" updateOn="keyup" keyup="{!c.logMe}" requiredIndicatorClass="slds-required"
required="true" value="{!v.myCustomClass.myTestStringNOTEXIST}" placeholder="Enter Me"
class="slds-input"/>
and access it as
console.log( ' 1.1 '+component.get('v.myCustomClass.myTestStringNOTEXIST'));
You will get the value but it is not the variable in controller.