问题
how can I get paragraph content text in textarea value
<p ng-model="extrap" >Some parragraph content</p>
<textarea ng-model="oneps"></textarea>
<script>
(function() {
angular
.module("TextAngularDemo", ['textAngular'])
.controller("DemoController", ['$scope', 'textAngularManager', DemoController]);
function DemoController($scope, textAngularManager) {
$scope.oneps = {{extrap}}
};
})();
</script>
I want paragraph text in textarea box with prefilled paragraph text
回答1:
I think you need to load a paragraph and text area with the same content, but you don't need to update the paragraph while the textarea value is changed. In that case you can go for one way data binding in angular js
.
This can be achieved by adding ::
inside your interpolation symbol like {{::yourModalValue}}
See the example below to see the implementation.
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.myParagraphContent = "Some initial content.";
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<b>Change the text area fild and see the change in me</b>
<p>{{myParagraphContent}}</p>
<b>Change the text area fild and see I won't be changes</b>
<p>{{::myParagraphContent}}</p>
<textarea ng-model="myParagraphContent"></textarea>
</div>
来源:https://stackoverflow.com/questions/58480823/how-to-get-paragraph-data-in-textarea-in-angularjs