Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Angular on fire #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion app/js/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Declare app level module which depends on ngRoute
angular.module('NoteWrangler', ['ngRoute', 'ngResource', 'Gravatar'])
angular.module('NoteWrangler', ['ngRoute', 'ngResource', 'Gravatar', 'firebase'])
.config(function($gravatarProvider){
$gravatarProvider.setSize(100);
});
9 changes: 7 additions & 2 deletions app/js/controllers/notes-index-controller.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
angular.module('NoteWrangler').controller('NotesIndexController', function($scope, Note, Session) {
angular.module('NoteWrangler')
.controller('NotesIndexController', function($scope, Note, Session) {
// Without NgResource
// Note.all().success(function(data) {
// $scope.notes = data;
// });

// With NgResource
$scope.notes = Note.query();

// With Firebase
// $scope.notes = Note();


Session.sessionData().success(function(sessionUser) {
// Create a new User from the session user data
$scope.loggedIn = !!sessionUser;
Expand Down
14 changes: 9 additions & 5 deletions app/js/controllers/users-index-controller.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
angular.module('NoteWrangler').controller('UsersIndexController', function($scope, User, $gravatar) {

angular.module('NoteWrangler')
.controller('UsersIndexController', function($scope, User, $gravatar) {

// Without NgResource
// User.all().success(function(data) {
// $scope.users = data;
// });

// With NgResource
$scope.users = User.query();

// $scope.users = User.query();

// With Firebase
$scope.users = User();

$scope.gravatarUrl = function(user) {
return $gravatar.generate(user.email);
}
Expand Down
26 changes: 24 additions & 2 deletions app/js/resources/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,30 @@ This is a way of handling ajax requests using NgResource, it performs a similar
to the Note Service.
*/

angular.module('NoteWrangler').factory('Note', function NoteFactory($resource) {
return $resource('/notes/:id', {}, {
// angular.module('NoteWrangler')
// .factory('Note', function NoteFactory($resource) {
// return $resource('/notes/:id', {}, {
// update: {
// method: "PUT"
// }
// });
// });

// Firebase way
// angular.module('NoteWrangler')
// .factory('Note', function NoteFactory($firebaseArray) {
// return function(){
// // creating the snapshot of our data
// var ref = new Firebase('https://notewrangler.firebaseio.com/notes');
// // return a synchronized array
// return $firebaseArray(ref);
// };
// });

// Firebase - Normal restful call
angular.module('NoteWrangler')
.factory('Note', function NoteFactory($resource) {
return $resource('https://notewrangler.firebaseio.com/notes/:id.json', {}, {
update: {
method: "PUT"
}
Expand Down
22 changes: 16 additions & 6 deletions app/js/resources/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ This is a way of handling ajax requests using NgResource, it performs a similar
to the UserService.
*/

angular.module('NoteWrangler').factory('User', function UserFactory($resource) {
return $resource('/users/:id', {}, {
update: {
method: "PUT"
}
});
// angular.module('NoteWrangler')
// .factory('User', function UserFactory($resource) {
// return $resource('/users/:id', {}, {
// update: {
// method: "PUT"
// }
// });
// });
//

angular.module('NoteWrangler')
.factory('User', function UserFactory($firebaseArray) {
return function(){
var ref = new Firebase('https://notewrangler.firebaseio.com/users');
return $firebaseArray(ref);
};
});
1 change: 1 addition & 0 deletions app/js/services/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This is for reference only, we favor using Note over this in the app.

angular.module('NoteWrangler')
.factory('Note', ['$http', function NoteFactory($http) {

return {
all: function() {
return $http({method: 'GET', url: "/notes"});
Expand Down
11 changes: 8 additions & 3 deletions app/server/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
</div>
</div>

<div class="nav-content-layout">
<!-- <div class="nav-content-layout">
<nw-session></nw-session>
<input class="form-input-search" type="text" placeholder="Search..." ng-model="search">
</div>
</div> -->

</div>
</div>
Expand All @@ -40,7 +40,7 @@
</div>
</div>
<div class="main-wrapper">
<div ng-view></div>
<div ng-view></div>
</div>

<!-- Vendors -->
Expand All @@ -55,6 +55,11 @@
<script src="/js/vendor/gravatar.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>

<!-- Firebase -->
<script src="https://cdn.firebase.com/js/client/2.2.2/firebase.js"></script>
<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/1.0.0/angularfire.min.js"></script>

<script src="/js/app.js"></script>
<script src="/js/routes.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion app/templates/directives/nw-category-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<i class="icon left {{category.icon}}"></i>
{{category.name}}
({{categoryCount()}})
<!-- ({{categoryCount()}}) -->

<i class="icon close"
ng-if='isActive()'
Expand Down
Loading