I have these function in one controller. I successfully imported the data, but I cannot use $add
, $remove
and $edit
. I Use $RootScope
because the items that are saved are in different state and hence different controller. I am new at this so I would really appreciate the help.
angular
.module("")
.factory("Factory",function($http,$firebaseArray){
var ref = new Firebase('https://****.firebaseio.com/');
return{
ref:$firebaseArray(ref)
}
});
$scope.saveItems = function() {
console.log($scope.item);
$rootScope.items.push($scope.item);
$scope.item = [];
$mdSidenav('right').close();
}
$rootScope.removeItems = function(item) {
var index = $rootScope.items.indexOf(item);
$rootScope.items.splice(index, 1);
};
$rootScope.editItems=function(item){
$rootScope.editing = true;
$mdSidenav('right').open();
$rootScope.item=item;
$rootScope.saveEdit=function(){
$rootScope.editing=false;
$mdSidenav('right').close();
};
};