[英]How to get paragraph data in textarea in angularjs?
如何在 textarea 值中获取段落内容文本
<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>
我希望文本区域框中的段落文本带有预填充的段落文本
我认为您需要加载具有相同内容的段落和文本区域,但您不需要在 textarea 值更改时更新段落。 在这种情况下,您可以 go 在angular js
中进行单向数据绑定。
这可以通过在您的插值符号中添加::
来实现,例如{{::yourModalValue}}
请参阅下面的示例以查看实现。
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.