I am working with HTML code that looks like this:
<div dir-paginate="x in comments | itemsPerPage: commentsPerPage">
HERE IS DIRECTIVE FROM BLEOW
</div>
My goal is to update the commentsPerPage
scope within the directive...
Below is a directive that is nested inside an ng-repeat loop:
angular.module('commentsApp')
.directive("addreply", addreply);
//ADD REPLY FUNCTION
function addreply(createCommentFactory)
{
//CREATING BUTTON FOR REPLY AND CALL LINK FUNCTION
var addReplys = {
link: link,
restrict: "EA",
transclude: true
};
return addReplys;
function link(scope, element, attrs)
{
scope.form = {
reply: ""
};
//CALL FACTORY TO ADD NEW REPLAY ON CLICK
element.bind('click', function () {
scope.addReply = function (el) {
createCommentFactory.saveComment(scope.form.reply[el.id], scope.project_id, el.id, el.level + 1)
.success(function (data) {
scope.commentsPerPage = scope.comments.length;
})
.error(function (data) {
console.log(data);
});
// RESET REPLY TEXT AREA
scope.form.reply = "";
};
});
}
}
I have attempted to update
scope.commentsPerPage = scope.comments.length;
, but it is not working as expected. Can anyone provide a solution for this?