AngularJS - ngShow is not working -


my view written follows:

<ul class="commentslist cf">         <li class="cf" ng-repeat="(key,comment) in activity.comments">           <div class="comment">{{comment.name}}             <div class="buttons" ng-show="isposteduser(activity.$id, key, currentuser)">               <button class="btn btn-delete tooltip"                 confirmation-needed = "are sure want delete activity?"                 ng-click="deletecomment(activity.$id,key)">                 <span>delete comment</span></button>             </div><!-- buttons -->           </div><!-- comment -->         </li>             </ul> 

in controller associated view, there function called:

$scope.isposteduser = function(actid, key, user) { var refcomment = new firebase(firebase_url + "users/" + $scope.whichuser + "/activities/" + actid +   "/comments/" + key); var commentobj = $firebase(refcomment).$asobject(); commentobj.$bindto($scope, "data").then(function() {   return $scope.data.giver === user.$id; }); 

};

the purpose of function display delete button isposteduser evaluates true. tested , evaluate true, still not display button. idea why?

let's rewrite function proper indentation:

$scope.isposteduser = function(actid, key, user) {     var refcomment = new firebase(firebase_url + "users/" + $scope.whichuser + "/activities/" + actid + "/comments/" + key);     var commentobj = $firebase(refcomment).$asobject();     commentobj.$bindto($scope, "data").then(function() {         return $scope.data.giver === user.$id;     }); }; 

now, can see function doesn't return (which means returns undefined, falsy).

the return statement code contains returns callback passed then() function. statement executed asynchronously, after isposteduser() has returned.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -