我想要使用textarea中的复选框数据并通过使用范围来获取段落中的textarea数据。我想在textarea中获取复选框数据并在{{newer}}中编辑数据并获取textarea数据。
我已经使用复选框范围在文本区域中添加了复选框值,并且在段落中也添加了文本区域范围
<div ng-app="myApp">
<input ng-model="er1" type="checkbox" ng-true-value="'10th / '" ng-false-value="">10th
<input ng-model="er2" type="checkbox" ng-true-value="'12th / '" ng-false-value="">12th
<input ng-model="er3" type="checkbox" ng-true-value="'B.Ed / '" ng-false-value="">bed
<textarea ng-model="newer">{{er1}}{{er2}}{{er3}}</textarea>
<p>{{newer}}</p>
</div>
var app = angular.module('myApp', []);
app.controller(function($scope) {
});
答案 0 :(得分:0)
使用ng-change
指令:
<input ng-model="er1" type="checkbox" ng-change="updateTextArea()"
ng-true-value="'10th / '" ng-false-value="">10th
<input ng-model="er2" type="checkbox" ng-change="updateTextArea()"
ng-true-value="'12th / '" ng-false-value="">12th
<input ng-model="er3" type="checkbox" ng-change="updateTextArea()"
ng-true-value="'B.Ed / '" ng-false-value="">bed
<textarea ng-model="newer">{{er1}}{{er2}}{{er3}}</textarea>
<p>{{newer}}</p>
app.controller(function($scope) {
$scope.updateTextArea = function() {
$scope.newer = $scope.er1 + $scope.er2 + $scope.er3;
};
});