javascript - Angular 1.xx and Firebase : Adding Subfolder or multidimensional array -
i new angular , programming , making simple web app.
data structure in firebase in image
i able create topics , display them on firebase console, cannot add lists under each topic in data structure image. editing , deleting topics work well.
admin.js:
.controller('adminctrl', ['$scope', '$firebase', '$firebasearray', '$firebaseobject', '$routeparams', function($scope, $firebase, $firebasearray, $firebaseobject, $routeparams) { $scope.id = $routeparams.id; var ref = firebase.database().ref().child('topics'); $scope.topics = $firebasearray(ref); $scope.addtopic = function() { $scope.topics.$add({ title: $scope.topic.title, curator: $scope.topic.curator, }); }; $scope.addlist = function(id) { //i dont know how add lists under each topic element. }; $scope.deletecnf = function(topic) { $scope.deletetopic = topic; }; $scope.deletepost = function(deletetopic) { $scope.topics.$remove(deletetopic); }; $scope.edittopic = function(id) { var ref = firebase.database().ref().child('topics/' + id); $scope.edittopicdata = $firebaseobject(ref); }; $scope.updatetopic = function(id) { var ref = firebase.database().ref().child('topics/' + id); ref.update({ title: $scope.edittopicdata.title, curator: $scope.edittopicdata.curator }).then(function(ref) { $('#editmodal').modal('hide'); }, function(error) { console.log(error); }) }; }]);
thanks!
Comments
Post a Comment