angular 从一个页面跳转到另一个页面(有传值),在另一个页面中显示从后台获取的数据,为啥获取不到

当前页面是一个list,点击某一条数据,跳转到另一个页面查看这条数据的详细内容。问题是:在当前页面可以获取到数据,不知为啥跳转到另一个页面后就没有获取到数据?
list页面

<table ng-repeat="product in item.products">
                        <tr>
                            <td class="tw_35">
                                <div class="picMsg" >
                                    <img src="" /><p>{{product.name}}</p><p>型号:{{product.price}}  颜色:{{item.color}}</p>
                                </div>
                            </td>
                            <td>
                                <span><a class="color0" ng-click="itemdetail (item.ocode)">详情</a></span>
                                
                            </td>
                        </tr>
                    </table>

list事件:


 $scope.itemdetail = function(id){
        //  alert(id)
        $state.go('itemdetailpage', {id: id});
        $scope.detailsss = [];
        //发送字段
        var detailoption = {'uid':1,'id':id}
        //
        var json ={
            "service":"服务路径",
            "reqData":detailoption 
        };
        //post
        $http({
            method : 'POST',
            url : posturl,
            data: json,
            header:headers
        }).success(function(data) {
            $scope.detailsss = data.respData;
        }).error(function(data){
            console.log(data.msg);
        })
    }

另一个页面-详情页:

<div ng-repeat="d in detailsss ">
    {{d}}
</div>
阅读 4.9k
2 个回答

把接收数据的数组的$scope改成了$rootScope

你没有向详情页传递具体数据啊,只传了id,
根据获取数据的代码不应该是写在详情页的吗
列表页做跳转就好啦

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题