when click comment or reply link form opening cards. how make particular scope such form should open link clicked.
the below function used ng-if in html hide form.once clicked should open corresponding form.
$scope.increasereply = function(object) { object.replyone += 1; };
you should assign replyactive bit each comment. that, can use iteration objects (i assumed using ng-repeat). can add 1 more property object interactively , use freely.
simple example;
var myapp = angular.module('myapp',[]); function myctrl($scope) { $scope.commentlist = [ { "author": "tugca eker", "comment": "you should check example..." }, { "author": "gagan", "comment": "ng-if not working" }, { "author": "tugca eker", "comment": "check again" } ]; }
ul li{ padding: 5px; border: 1px solid black; }
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-controller="myctrl"> <ul> <li ng-repeat="comment in commentlist" ng-init="comment.isreplyactive = false;"> <b>{{comment.author}}</b>: {{comment.comment}} <br /> <a ng-click="comment.isreplyactive = !comment.isreplyactive;">reply now!</a> <div ng-if="comment.isreplyactive"> <input type="text"> </div> </li> </ul> </div>
snippet on stackoverflow fails, don't know why. check fiddle, http://jsfiddle.net/lvc0u55v/7762/
Comments
Post a Comment