我无法添加帖子。提交表单后,它不会显示在帖子列表中。
我的控制器是:
myapp.controller('PostsCtrl', function ($scope, Post) {
$scope.posts = [];
$scope.post = {url: 'http://', title: ''};
$scope.submitPost = function() {
Post.save($scope.post, function (ref) {
$scope.posts[ref.name] = $scope.post;
$scope.post = {url: 'http://', title: ''};
});
};
$scope.deletePost = function (postId) {
Post.delete({id: postId}, function () {
delete $scope.posts[postId];
});
};
});
广告模板是:
<div ng-repeat="(postId, post) in posts">
<a href="{{ post.url }}">{{ post.title }}</a>
<a ng-click="deletePost(postId)">delete</a>
</div>
<form ng-submit="submitPost()">
<input type="text" ng-model="post.title" />
<input type="text" ng-model="post.url" />
<input type="submit" value="Add Post" />
</form>
refbase名称值是由Firebase响应设置的,但它似乎不是帖子地图的有效键类型。
我想知道我错过了什么......
亲切的问候,
Stephane Eybert