【发布时间】:2016-09-04 13:32:57
【问题描述】:
我在一个控制器中拥有这些功能。我成功导入数据,但无法使用$add、$remove 和$edit。我使用$RootScope,因为保存的项目处于不同的状态,因此是不同的控制器。我是新手,所以非常感谢您的帮助。
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();
};
};
【问题讨论】:
标签: angularjs firebase angularfire firebase-realtime-database