I'm using PHP with AngularJS and I want to set the default value to the textarea.
我正在使用PHP与AngularJS,我想将默认值设置为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.
但是,我不想使用ng-init =“textarea =''”因为我想要填充的数据非常大。我不想使用AJAX,因为这会向服务器添加另一个请求。
Is there a way I can set the value with PHP directly like
有没有办法可以直接用PHP设置值
<textarea ng-model="textarea"><?php echo $data ?></textarea>
Doing this shows nothing because Angular wants me to use a model to set the value.
这样做没有显示任何内容,因为Angular希望我使用模型来设置值。
Current HTML
<textarea ng-model="textarea" class="textarea"></textarea>
Current AngularJS & JQuery
目前的AngularJS和JQuery
$scope.jqta = $('.textarea');
$.get("/fetch", function(response) {
$scope.jqta.text(response);
});
1 个解决方案
#1
0
Using HTML:
<textarea ng-model="textarea" class="textarea">Default value</textarea>
If that doesn't work:
如果这不起作用:
$scope.textarea = 'Default value';
#1
0
Using HTML:
<textarea ng-model="textarea" class="textarea">Default value</textarea>
If that doesn't work:
如果这不起作用:
$scope.textarea = 'Default value';