Easy User Comment Box using AngularJS

Easy User Comment Box using AngularJS

Easy User Comment Box 

Step by step instructions to make a basic remark box utilizing AngularJS. Extraordinary compared to other well known Javascript systems is AngularJS utilizing this we going to do the remark box. Remark is an extraordinary approach to express about a specific thing so this strategy ought to be quick on the grounds that everybody detests the ease back procedure to post the remark about any point. So in this AngularJS will post a speedy remark.

Live Demo   Download Source Code

Index.html

<div class="form-group">
        <h2>Leave a Replay</h2>
        <form ng-controller="Controller">
            <textarea class="form-control" rows="5" ng-model="cmtName" placeholder="Your Comment"></textarea>
            <br/>
            <button class="btn btn-success btn-md pull-right" ng-click='btn_post();'>Comment</button>
            <br/>
            <hr/>
            <h3>Comments</h3>
            <ul class="list-group">
                <li class="list-group-item" ng-repeat="cmt in comments"> {{ cmt }}
                    <a href="" ng-click="post_cmt($home)"><span class="glyphicon glyphicon-trash" style="color:red; float:right;"></span></a>
                </li>
            </ul>
        </form> 
    </div>

Script.js

<script type="text/javascript">
function Controller($scope) {
     $scope.comments = [];
     $scope.btn_post = function() {
         if ($scope.cmtName != '') {
             $scope.comments.push($scope.cmtName);
             $scope.cmtName = "";
         }
     }
     $scope.post_cmt = function($home) {
         $scope.comments.splice($home, 1);
     }
 }
</script>

 

You May Also Like

About the Author: admin

4 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *