我有一个名为" UserSnapshot"在Parse上,当然在填充表格时会得到objectID。
然而,当我从我的应用程序查询表中的某个对象时,我没有对象ID,但是我将拥有他们的" UserCode"。我一直在玩这样的东西。
.controller('NewsCtrl', function($scope,
$ionicLoading,
FreshlyPressed, $stateParams) {
$scope.posts = [];
$scope.doRefresh = function() {
$scope.posts = FreshlyPressed.getBlogs($scope);
$scope.$broadcast('scroll.refreshComplete');
}
$scope.doRefresh();
})
.service('FreshlyPressed', function($http) {
return {
getBlogs: function($scope) {
$scope.postsURL = 'http://urbanetradio.com/wp-json/posts?_jsonp=JSON_CALLBACK';
$http.jsonp($scope.postsURL).success(function(data, status, headers, config) {
$scope.posts = data;
});
},
getPostById: function(postId) {
var url ='http://urbanetradio.com/wp-json/posts/'+ postId;
return $http.get(url);
}
}
})
.controller('PostDetailCtrl', function($scope, $stateParams, FreshlyPressed) {
var postId = $stateParams.postId;
console.log( $stateParams)
FreshlyPressed.getPostById(postId).success(function(response){
$scope.post = response;
})
});
但没有任何反应。没有输入if或else。我错过了什么吗?
由于
答案 0 :(得分:0)
在日志/控制台中是否打印出任何内容?在App Delegate中初始化Parse时,您可能没有正确设置密钥。
答案 1 :(得分:0)
PFQuery *userProfile = [PFQuery queryWithClassName:@"UserSnapshot"];
[userProfile whereKey:@"Code" equalTo:_Code];
PFObject *object = [userProfile getFirstObject];
作品!