Basic angularFire options: $save, $add and $remove.

The way connect firebase:

var app = angular.module('app', ['firebase']);
    var ref = new Firebase(FIREBASE_URI);
//create an item storage
var items = $firebase(ref);

Example:

<!DOCTYPE html>
<html ng-app="app">
<head lang="en">
<meta charset="UTF-8">
<title>Angular Firebase</title>
<link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/> </head>
<body ng-controller="MainCtrl">
<table class="table edit">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Count</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(id, item) in items">
<td><input type="text" ng-model="item.name" ng-blur="updateItem(id)"/></td>
<td><input type="text" ng-model="item.description" ng-blur="updateItem(id)"/></td>
<td><input type="text" ng-model="item.count" ng-blur="updateItem(id)"/></td>
<td>
<a href="#" ng-click="removeItem(id)" class="navbar-link">Remove</a>
</td>
</tr>
</tbody>
</table> <div class="well">
<h4>Add Item</h4> <form class="form-inline" role="form" novalidate ng-submit="addItem()">
<div class="form-group">
<input type="text" class="form-control" ng-model="newItem.name" placeholder="Name">
</div>
<div class="form-group">
<input type="text" class="form-control" ng-model="newItem.description" placeholder="Description">
</div>
<div class="form-group">
<input type="text" class="form-control" ng-model="newItem.count" placeholder="Count">
</div>
<button type="submit" class="btn btn-default">Add</button>
</form>
</div> <script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>
<script src="https://cdn.firebase.com/v0/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/0.6.0/angularfire.js"></script>
<script src="public/js/app.js"></script>
</body>
</html>
/**
* Created by Answer1215 on 11/9/2014.
*/ var app = angular.module('app', ['firebase']); app.constant('FIREBASE_URI', 'https://<your_app>.firebaseio.com/'); app.controller('MainCtrl', ['$scope', 'ItemsService', function ($scope, ItemsService) {
$scope.newItem = { name: '', description: '', count: 0 };
$scope.currentItem = null; $scope.items = ItemsService.getItems(); $scope.addItem = function () {
ItemsService.addItem(angular.copy($scope.newItem));
$scope.newItem = { name: '', description: '', count: 0 };
}; $scope.updateItem = function (id) {
ItemsService.updateItem(id);
}; $scope.removeItem = function (id) {
ItemsService.removeItem(id);
};
}]); app.factory('ItemsService', ['$firebase', 'FIREBASE_URI', function ($firebase, FIREBASE_URI) {
var ref = new Firebase(FIREBASE_URI);
var items = $firebase(ref); var getItems = function () {
return items;
}; var addItem = function (item) {
items.$add(item);
}; var updateItem = function (id) {
items.$save(id);
}; var removeItem = function (id) {
items.$remove(id);
}; return {
getItems: getItems,
addItem: addItem,
updateItem: updateItem,
removeItem: removeItem
}
}]);

Also take a look the Forge, The easy way you can go to your app's forage is copy paste the FIREBASE_URI into boswer.

In Forge, you can modify, remove or add the data. Also you can import JSON format data into the Forage, all those things happen in real time.

[Firebase] 1. AngularFire, $save, $add and $remove, Forge的更多相关文章

  1. eclipse tomcat add and remove工程异常

    1  eclipse导入工程后,右击server add and remove工程时,there are no resource: 解决方案:右击工程->单击property->选择pro ...

  2. eclipse中tomcat使用add and remove无法发布web项目

    继上次启动eclipse中的tomcat报classNotFound的问题后,这次又遇到新问题.就是右键点击tomcat使用add and remove发布web项目至tomcat后,启动tomcat ...

  3. [置顶] 有关ListIterator接口的add与remove方法探究

    ListIterator接口继承自Iterator接口,新增了add()等方法. 关于ListIterator的add()方法的作用(接口是没有方法实现的,但其实现类对于add()方法的实现机制大致相 ...

  4. Arrays.asList 为什么不能 add 或者 remove 而 ArrayList 可以

    分析如下例子: 1 import java.util.Arrays; 2 import java.util.List; 3 4 5 public class Test { 6 public stati ...

  5. eclipse中tomcat的add and Remove找不到项目

    在我们运行项目前,都需要将项目部署到tomcat上,但是有时我们会遇到这种情况:项目明明存在,但是eclipse中tomcat的add and remove找不到项目,无法部署,那么这个问题该如何解决 ...

  6. 数组转换为List(Arrays.asList)后add或remove出现UnsupportedOperationException

    Java中,可以使用Arrays.asList(T... a)方法来把一个数组转换为List,返回一个受指定数组支持的固定大小(注意是固定大小)的列表.此方法同 Collection.toArray( ...

  7. 【java】在分页查询结果中对最后的结果集List进行操作add()或remove()操作,报错:java.lang.UnsupportedOperationException

    场景: 在分页查询结果中对最后的结果集List进行操作add()或remove()操作,报错:java.lang.UnsupportedOperationException 错误: java.lang ...

  8. Arrays.asList()后调用add,remove这些method时出现java.lang.UnsupportedOperationException异常

    String[] queryNames = request.getParameterValues("queryName"); List<String> queryNam ...

  9. 为什么Java里的Arrays.asList不能用add和remove方法?

    在平时的开发过程中,我们知道能够将一个Array的对象转化为List.这种操作,我们仅仅要採用Arrays.asList这种方法即可了.笔者前段时间一直用这种方法,有一天,我发现通过Arrays.as ...

随机推荐

  1. (转) redis的事务和watch

    redis的事务 严格意义来讲,redis的事务和我们理解的传统数据库(如mysql)的事务是不一样的. redis中的事务定义 Redis中的事务(transaction)是一组命令的集合. 事务同 ...

  2. 【SQL】175. Combine Two Tables

    Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...

  3. 谈HTTPS中间人攻击与证书校验(一)

    一.前言 随着安全的普及,https通信应用越发广泛,但是由于对https不熟悉导致开发人员频繁错误的使用https,例如最常见的是未校验https证书从而导致“中间人攻击”,并且由于修复方案也一直是 ...

  4. 1.8(SQL学习笔记)触发器

    一.触发器简介 当需要某些操作在某些语句执行之前或之后执行就需要使用触发器. 例如每次插入数据时进行数据校对,每次删除数据后将删除内容备份到新表. 这些操作我们希望它(某些语句)在满足某些条件时自动执 ...

  5. bzoj 1211: [HNOI2004]树的计数 -- purfer序列

    1211: [HNOI2004]树的计数 Time Limit: 10 Sec  Memory Limit: 162 MB Description 一个有n个结点的树,设它的结点分别为v1, v2, ...

  6. JSP -- include指令与include动作的区别

    JSP -- include指令与include动作的区别 (1)格式的区别: include指令:<%@include file = "文件名"%> include动 ...

  7. svm算法介绍

    在一个理想的分类当中,我们想要用一个超平面来将正类样本和负类样本划分开来.这个超平面的方程为 $\mathbf{w}^T\mathbf{x}+b=0$ 我们希望这个超平面能够使得划分更加的鲁棒,在图形 ...

  8. iOS开发经验总结——基础工程

    iOS开发经验总结--依赖库 这篇博客,我想说一下开发中经常遇到的一个问题,虚拟个场景描述一下的话,应该是这样的. 项目经理:今天我们正式开始一个新项目,iOSer你负责把苹果端的APP完成,有没有问 ...

  9. VS2012项目中使用CocoStudio相关文件的设置

    开发环境说明: win7  vs2012  coco2d-x 3.0 alpha1 cocos2d-x 3.0 alpha 1搭配CocoStudio使用,效果更佳.CocoStudio包含了游戏开发 ...

  10. ADC Power Supplies

    http://www.planetanalog.com/author.asp?section_id=3041&doc_id=563055 Jonathan Harris, Product Ap ...