function SettingCtrl( $scope, $location, User ){
$scope.selectedMembership = User.membershipquery();
console.log($scope.selectedMembership);
console.log($scope.selectedMembership.id); //why returned undefined
}
它会在控制台中给我,
g {} ad_post_limit:" -1" ads_active_limit:" -1" ads_validity: nullcategories_limit:" -1" category_floor_help_alert: " 6" category_floor_sale_alert:" 5" contact_notification:" 10"费用: " 0.00" extra_ads_listing_price:" 25.00" extra_featured_ads_price: " 5.00" featured_ads_limit:" 10" featured_ads_validity: " 30" floor_help_alert:" 6" floor_sale_alert:" 3" id:" 1" max_ads_image: " 2" membership_title:"免费会员资格" quote_notification:" 10" slug: "免费会员资格"有效期:" -1" 原型:对象[]
未定义
如何在我的控制器功能中获取该特定值并使用该操作进行操作。
答案 0 :(得分:0)
$ scope.selectedMembership存在问题。从您的控制台日志看,它看起来不是json格式,因为$ scope.selectedMembership.id总是给出undefined,因为它没有得到一个正确的对象来读取id的值。