0
ボタンをクリックしたときに、どのように角度を付けてコメントを配置するのですか?フィールド入力とテキストエリアに何らかのテキストを入力するたびに、テキストはなくなります。名前、国、コメントのない空白ブロックが表示されます。入力したテキストは、既存のjsonの後にプッシュする必要があります。フィールド入力に入力したテキストをプッシュしてjsonの角度にテキストエリアを押す方法
angular.module("forum-page", ["myApp"])
\t .controller("Forum", function($scope) {
\t \t $scope.comments = [
\t \t \t {
\t \t \t "name": "Kevin",
\t \t \t "comment": "Wat een mooi toestel vandaag ontvangen, zeer blij met mijn bestelling :)",
\t \t \t "country": "Nederland"
\t \t \t },
\t \t ];
\t $scope.addComment = function() {
\t \t $scope.comments.push({"name": $scope.name, "comment": $scope.comment, "country": $scope.country});
\t \t $scope.dataObject = {
\t \t \t name: $scope.name,
\t \t \t comment: $scope.comment,
\t \t \t country: $scope.country
\t \t };
\t \t
\t \t $scope.name = "";
\t \t $scope.comment = "";
\t \t $scope.country = "";
\t };
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<tr>
<tr><input type="text" id="comment-name" class="comment-form" ng-model="dataObject.name"/></tr>
<tr><input type="text" id="comment-country" class="comment-form" ng-model="dataObject.country"/></tr>
<tr><textarea type="text" id="comment-box" class="comment-form" ng-model="dataObject.comment"/></textarea></tr>
<tr><button ng-click="addComment()">Place comment</button></tr>
</tr>
男性に感謝し、この答えはそれほど単純だと思ったことはありません。ヒーロー! –