Its very clear that Bind expression do work .
To test this I invoked the static method simply from the developer console and it worked .
TestAccountCtrl.returnAccountsAsTest(5);
This made me suspect that this has to do with lightning component variable not getting passed as the integer as it should be .
Also specifically it has to do only when we have design file attribute mapped to the attribute of component .I feel its a bug within SFDC and needs to forwarded to lightning components team as docs clearly do mention that integer is supported in design file .
Here is another weird observation .I just changed the type of your attribute to String and it does work .
<aura:component implements="force:appHostable" controller="TestAccountCtrl">
<aura:attribute name="limitAmount" type="String" default="5"/>
<aura:attribute name="accountlst" type="Account"/>
<aura:handler name="init" value="{!this}" action="{!c.retrieveAccounts}" />
<div>
<ul>
<aura:iteration items="{!v.accountlst}" var="acc">
<li>{!acc.Id}</li>
</aura:iteration>
</ul>
</div>
I came up with workaround solution if you still want to keep type as Integer and it works is as below
<aura:component implements="force:appHostable" controller="TestAccountCtrl">
<aura:attribute name="limitAmount" type="Integer" default="5"/>
<aura:attribute name="accountlst" type="Account"/>
<aura:handler name="init" value="{!this}" action="{!c.retrieveAccounts}" />
<div>
<ul>
<aura:iteration items="{!v.accountlst}" var="acc">
<li>{!acc.Id}</li>
</aura:iteration>
</ul>
</div>
The modified controller code
public with sharing class TestAccountCtrl {
@AuraEnabled
public static List<Account> returnAccountsAsTest(Integer amount) {
Integer liamount = integer.valueof(amount);
List<Account> accounts = [SELECT Id FROM Account LIMIT : liamount];
return accounts;
}
}
In case you need helper file for reference ,here is below
({
"retrieveAccounts" : function(cmp) {
var action = cmp.get("c.returnAccountsAsTest");
action.setParams({ amount : cmp.get("v.limitAmount") });
action.setCallback(this, function(response) {
// process state here
cmp.set("v.accountlst", response.getReturnValue());
});
$A.enqueueAction(action);
}
})
This is just work around and I am sure this is a bug in SFDC lightning components .Let me file a bug with support .
Latest update:::
I reached out to the lightning component team and they have confirmed its bug in the serializer .I will be opening a case with them and hopefully they fix it.
Best Answer
Embarrassing to answer you own question but I figured I'd leave a response just in case someone else needs it!
Because I was using...
... Using "+=" rather than "=", Salesforce is appending the date to what I assume is "null".
Rookie mistake but hopefully this might help someone!
Thanks.