everything!
Excuse me for my poor English, please ask me and I will try to explain more.
I am learning angular with the sample operation of http://thinkster.io , and I noticed in lesson 4 that it uses the old version of angularfire (I think it is less than 2), and the syntax of the latter has been changed. I tried to make changes to my code for v2 (for example, I added the $ asArray () element to return $ firebase, and $ add and $ remove started to work. But my find method did not, and $ keyAt returns null. Where is my false?
post.js:
'use strict'; app.factory('Post', function ($firebase, FIREBASE_URL) { var ref = new Firebase('https://torid-fire-6813.firebaseio.com/posts'); var posts = $firebase(ref).$asArray(); var Post = { all: posts, create: function (post) { return posts.$add(post); }, find: function (postId) { return posts.$keyAt(postId); }, delete: function (postId) { return posts.$remove(postId); } }; return Post; } );
and postview.js, where the 'find' method is used:
'use strict'; app.controller('PostViewCtrl', function($scope, $routeParams, Post){ $scope.post = Post.find($routeParams.postId); });
source share