Skip to content

Instantly share code, notes, and snippets.

@awhedbee22
Created December 1, 2014 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awhedbee22/a8de21ac8f76a1224883 to your computer and use it in GitHub Desktop.
Save awhedbee22/a8de21ac8f76a1224883 to your computer and use it in GitHub Desktop.
angular.module('vegas.controllers', [])
// Data for this seed is stored in the "awvegas" firebase.
// To view the raw data, open https://awvegas.firebaseio.com/.json in a browser
// A simple controller that fetches a list of data from a service
.controller('ScheduleIndexCtrl', function($scope, $firebase) {
// "Items" is a service returning mock data (services.js)
var ref = new Firebase('https://awvegas.firebaseio.com/items');
$scope.items = $firebase(ref);
})
// A simple controller that shows a tapped item's data
.controller('ScheduleDetailCtrl', function($scope, $stateParams, $firebase) {
// "Item" is a service returning mock data (services.js)
var ref = new Firebase('https://awvegas.firebaseio.com/items/' + $stateParams.itemId);
$scope.items = $firebase(ref);
})
// A simple controller which adds a new Item
.controller('AddCtrl', function($scope, $stateParams, $firebase, $log, $location) {
var ref = new Firebase('https://awvegas.firebaseio.com/items/');
$scope.items = $firebase(ref);
$scope.createItem = function (item) {
var ref = $scope.items.$add(item);
$scope.item = {};
$log.info("Your data has been saved to https://awvegas.firebaseio.com/items/" + ref.name() + ".json");
alert(" Your item has been saved!");
$location.path("/");
};
});
<view title="'Schedule'">
<content has-header="true" has-tabs="true">
<list>
<item ng-repeat="item in items" type="item-text-wrap" href="#/tab/schedule/{{items.id}}">
<h3>{{items.title}}</h3>
<p>{{items.description}}</p>
</item>
</item>
</list>
</content>
</view>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment