Moe Moe - 2 months ago 26x
AngularJS Question

Set default value to a textarea (AngularJS)

I'm using PHP with AngularJS and I want to set the default value to the textarea.

However, I do not want to use

ng-init="textarea = ''"
because the data that I want to populate is quite large. I do not want to use AJAX either because that adds another request to the server.

Is there a way I can set the value with PHP directly like

<textarea ng-model="textarea"><?php echo $data ?></textarea>

Doing this shows nothing because Angular wants me to use a model to set the value.

Current HTML

<textarea ng-model="textarea" class="textarea"></textarea>

Current AngularJS & JQuery

$scope.jqta = $('.textarea');

$.get("/fetch", function(response) {


Using HTML:

<textarea ng-model="textarea" class="textarea">Default value</textarea>

If that doesn't work:

$scope.textarea = 'Default value';