1
push를 위해 $ add를 대체하려고하면이 오류가 발생합니다.
TypeError: undefined is not a function
at Scope.$scope.sendComment (http://localhost:9000/scripts/controllers/post.js:22:38)
at http://localhost:9000/bower_components/angular/angular.js:10847:21
...
여기
16 $scope.sendComment = function() {
17 var newComment = {
18 user: $scope.currentUser,
19 text: $scope.currentText
20
21 };
22 var promise = CommentService.add(newComment);
23 promise.then(function(name) {
24 console.log(name);
25 });
26 };
여기 내 서비스의 post.js @ 내 컨트롤러 나는이 밤에 붙어 있었어요
(function(angular) {
'use strict';
angular.module('codesApp').service('CommentService', function(FBURL, $q, $firebase) {
var commentRef = new Firebase(FBURL).child('comments');
var fireComment = $firebase(commentRef);
return {
childAdded: function childAdded(limitNumber, cb) {
commentRef.startAt().limit(limitNumber).on('child_added', function(snapshot) {
var val = snapshot.val();
cb.call(this, {
user: val.user,
text: val.text,
name: snapshot.name()
});
});
},
add: function addComment(comment) {
return fireComment.$add(comment);
},
....
(문제가있는 추가 기능이 바닥을 향) . 어떤 도움이라도 대단히 감사합니다! 감사!
그것은'약속 있어야하지 수 $. 23 번 줄에? –