Hello I am building an app using Firebase and AngularJS. I have two parents, one containing every monster in the game, and another containing every monster the user has.
I need a repeater that blanks out the users monsters, and displays everything else. I have tried many methods, and I feel using a directive I am very close to something logical.
index.html:
<div ng-repeat="monster in monsters" my-directive="monster">
<h2>{{monster.name}}</h2>
</div>
services.js
.directive('myDirective', function(Auth, $firebaseArray){
rdef =''
Auth.$onAuth(function(authData) {
var username = authData.uid;
var ref = new Firebase("firebaseurl");
var hopref = ref.child(username);
var results = $firebaseArray(hopref);
results.$loaded(function(x) {
angular.forEach(results, function(value, key){
if(myDirective.name == value.Monster){
rdef ='<div></div>'
}else{
rdef ='<div>{{ myDirective.name }}</div>'
}
});
});
});
return {
restrict: "A",
template: rdef ,
scope: {
myDirective: '='
},
link: function(scope, element, attrs) {
console.log('MyData', scope.myDirective);
}
};
});
I am quite new to Angular, and any help would be very much appreciated. (I am also new to Stackoverflow so if im doing something wrong, please let me know)
Thank you!!!