我有一个玉器文件:
img.profileImg(src="{{ identity.currentUser.profilePic }}")
.profileData {{ identity.currentUser.firstName }}
textarea#post-form.form-control(ng-model='activity.body')
button#post-btn.btn(ng-click="addpost(activity, identity.currentUser.profilePic,identity.currentUser.firstName,identity.currentUser.lastName)") Link
这是我的addpost functoin:
addpost: function(activity){
var deferred = $q.defer();
var activity = new ActivityResource(activity);
activity.profilePic = profilePic;
activity.firstName = firstName;
activity.lastName = lastName;
activity.$save().then(function(){
deferred.resolve();
}, function(response){
deferred.reject(response);
});
return deferred.promise;
}
activity.body保存到mongodb但其余的(firstName,lastName,profilePic)没有保存到数据库,有什么建议吗?我的Skype是svetla_venci1,我真的需要这个紧急情况。在此先感谢:)
答案 0 :(得分:1)
你应该可以这样做:
- 在视图中将您的ID添加到电话
button#post-btn.btn(ng-click="addpost(activity, identity.currentUser._id)") Link
- 在你的方法中:
addpost: function(activity, id){
var deferred = $q.defer();
var activity = new ActivityResource(activity);
activity.userId = id;
activity.$save().then(function(){
deferred.resolve();
}, function(response){
deferred.reject(response);
});
return deferred.promise;
}