Initially, the re...">All geek questions in one placeThe default textarea value in angularjs when textarea is model boundHTML:<textarea ng-model="user.ban_reason"></textarea> Initially, the reason for the ban is empty. However, I want to specify a default value. But <textarea ng-model="user.ban_reason">reason</textarea> Does not work.Any ideas how to do this?+4javascript angularjsLost in owl Aug 14 '13 at 13:21source share3 answersInside your controller, you can do the following: $scope.user = { ban_reason:"reason" } +7AlwaysALearner Aug 14 '13 at 13:23source shareYour angular application initializes when the DOM documents are ready - thus overriding the value using the value of $scope.user.ban_reason .In your controller, define a default value for the model property: $scope.user = { ban_reason: 'reason' }; +3fjdumont Aug 14 '13 at 13:24source shareWell, if there is a situation that you still need for the default text to be used in the template, you can use ng-init. <textarea ng-model="text" ng-init="text = 'Hello, this is my default text.'"></textarea> +3Lukas Jelinek Dec 03 '14 at 2:41source shareSource: https://habr.com/ru/post/1497033/More articles:procedure for sorting a two-dimensional int array depending on a column - javaWhen I launch the application, only the web engine works in GlassFish. "webservices" is not running - glassfishA simple request to create an object - javaProblem with PlaceHolder + @ Html.TextBox - c #How can I override the type-by-type XML serialization format in servicestack - servicestackSimple HTML rendering problem - htmlUsing Python to count working days per month? - pythonVlookup optimization with multiple criteria (index + match) - optimizationOS X Xcode / clang for creating Windows executables? - cJavaFX ImageView memory leak - javaAll Articles
HTML:
<textarea ng-model="user.ban_reason"></textarea>
Initially, the reason for the ban is empty. However, I want to specify a default value. But
<textarea ng-model="user.ban_reason">reason</textarea>
Does not work.
Any ideas how to do this?
Inside your controller, you can do the following:
$scope.user = { ban_reason:"reason" }
Your angular application initializes when the DOM documents are ready - thus overriding the value using the value of $scope.user.ban_reason .
$scope.user.ban_reason
In your controller, define a default value for the model property:
$scope.user = { ban_reason: 'reason' };
Well, if there is a situation that you still need for the default text to be used in the template, you can use ng-init.
<textarea ng-model="text" ng-init="text = 'Hello, this is my default text.'"></textarea>
Source: https://habr.com/ru/post/1497033/More articles:procedure for sorting a two-dimensional int array depending on a column - javaWhen I launch the application, only the web engine works in GlassFish. "webservices" is not running - glassfishA simple request to create an object - javaProblem with PlaceHolder + @ Html.TextBox - c #How can I override the type-by-type XML serialization format in servicestack - servicestackSimple HTML rendering problem - htmlUsing Python to count working days per month? - pythonVlookup optimization with multiple criteria (index + match) - optimizationOS X Xcode / clang for creating Windows executables? - cJavaFX ImageView memory leak - javaAll Articles