I'm trying to render a default message on a textarea using AngularJS. Some of the values I'm trying to add requires the use of $timeout
in order to obtain the values.
The message doesn't seem to render using the code below:
<textarea class="text-input referral-message" ng-init="message=buildMessage(purchase_count)"
ng-model="message" rows="5">
</textarea>
$timeout(function() {
ReferralService.settings().$promise.then(function(settings) {
$scope.purchase_count = settings.credits;
});
$scope.buildMessage = function(val){
return "Buy " + val + " and get 1 free for every purchase"
}
}, 1);