angularjs - Displaying two tables within a loop -
I am very new to AngularJS, I am using it with the Firebase.
I have a set of data like this:
"userId1": {"name": "Bobby", "comments": {"-J_v90hh5sbJ2acmX4nq" : True}}
and a comment list
"- J_v90hh5sbJ2acmX4nq": {"CREATION_DATE": 1415110466568, "creator_id": "userId1", " Desc ":" dsqdsq "," type ":" suggestion "}
So what I want to do is display all the comments of our friend Bobby.
.controller ('CommentsCtrl', function ($ scope, $ firebase) {var creator_id = 'userId1'; // test objectives userCommentsRef = new Firebase ("https: // terrible. CommentsRef = new Firebase ("https://awesome.firebaseio.com/comments"); on userCommentsSync = $ firebase (userCommentsRef); commentsSync = $ firebase on firebaseio.com/users/"+creator_id+'/comments' (CommentsRef); UserComments = userCommentsSync $ asObject (); Comment on commentsSync $ asObject (.); $ Scope.userComments = userComments; $ scope.c Omments = Comments;})
< P> Do you know how I should proceed with this display, but to ensure that the tips Nian who went deleted (and the key is still there), details will not be displayed? & lt; Ion-list NG-controller = "comments ttl" & gt; & Lt; Ul class = "list" & gt; & Lt; Li class = "item items-checkbox item-checkbox-correct" ng-repeat = "(key, item) user comments" & gt; {{Comments [key] .desc}} // Working, but do not want deleted comments & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Ion list & gt;
Is this the right way to handle this situation? How can I tell my controller to display only existing comments?
After the
You can use the ng-repeat filter to block like this:
& lt; Li ng-repeat = "(cue, item) in userComments | filter: {deleted: false}" & gt; {{Comments [key] .desc}} // Working, but do not want deleted comments & lt; / Li & gt;
Or, if the information stored in the information object is ng-if
:
& lt; Li ng-repeat = "(key, object) in filter: {deleted: false}" ng-if = "! [Key] .deleted" & gt; {{Comments [key] .desc}} // Working, but do not want deleted comments & lt; / Li & gt;
Comments
Post a Comment