Javascript 如何使用其他textarea编辑textarea值?

Javascript 如何使用其他textarea编辑textarea值?,javascript,jquery,angularjs,angularjs-directive,Javascript,Jquery,Angularjs,Angularjs Directive,我有一个文本区域框,其值为“一些初始内容” 我想用另一个文本框编辑它的值 var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { $scope.myParagraphContent = "Some{{SecondTextareaContent}} initial content."; }); {{myParagraphContent} 我试着理解你。像这样的 const t

我有一个文本区域框,其值为“一些初始内容” 我想用另一个文本框编辑它的值

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.myParagraphContent = "Some{{SecondTextareaContent}} initial content.";
});

{{myParagraphContent}


我试着理解你。像这样的

const txt=document.queryselectoral(“.txt”);
常量设置值=()=>{
txt[1]。值=txt[0]。值;
}
txt[0]。addEventListener(“输入”,设置值,false)

更新 您可以使用ngChange代替。查看演示

对于Javascript部分:

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
     $scope.SecondTextareaContent = '';
     $scope.myParagraphContent = 'Some initial content.';
     $scope.onChange = function() {
        $scope.myParagraphContent = 'Some ' + $scope.SecondTextareaContent + ' initial content.';
     };
});
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
     $scope.SecondTextareaContent = '';
     $scope.myParagraphContent = 'Some initial content.';
     $scope.onKeyDown = function() {
        $scope.myParagraphContent = 'Some ' + $scope.SecondTextareaContent + ' initial content.';
     };
});
对于HTML部分:

<textarea ng-model="SecondTextareaContent" ng-change="onChange()"></textarea>
<textarea ng-model="myParagraphContent"></textarea>
<textarea ng-model="SecondTextareaContent" ng-keydown="onKeyDown()"></textarea>
<textarea ng-model="myParagraphContent"></textarea>
对于HTML部分:

<textarea ng-model="SecondTextareaContent" ng-change="onChange()"></textarea>
<textarea ng-model="myParagraphContent"></textarea>
<textarea ng-model="SecondTextareaContent" ng-keydown="onKeyDown()"></textarea>
<textarea ng-model="myParagraphContent"></textarea>

您可以这样做

<div ng-app="myApp" ng-controller="myCtrl">

<p>{{myParagraphContent}}</p>

<textarea ng-model="SecondTextareaContent" ng-change='myParagraphContent=SecondTextareaContent'></textarea>
<textarea ng-model="myParagraphContent"  ></textarea>

</div>

{{myParagraphContent}


另外,如果您想在ng中进行更改,您可以使用一些函数来执行。

不工作,当我键入SecondTextareaContent时,它显示的是parragraph:some${$scope.SecondTextareaContent}初始内容。删除了模板文字。现在就试试当我键入“demo”时,它只显示“dem”最后一个字符丢失;当我只键入一个字符时,myParagraphContent中没有任何值