我有一个控制器,它将保存地址数据,并通过以下方式将位置(使用$location.path("/checkout/"+ $scope.checkOutAddress);)更改为下一页,并将json响应作为参数
$routeProvider.when('/checkout/:checkOutAddress', {
templateUrl : 'partials/checkOut.html',
controller : 'myController'
}); 在尝试使用以下代码获取值的结帐控制器中
mCommerceApp.controller('myController', function($scope,$sessionStorage,$location,$routeParams,MCommerceService) {
$scope.checkOutAddress=$routeParams.checkOutAddress;
console.log($scope.checkOutAddress);
});所以现在的问题是我不能得到json值。它是作为一个对象出现的。浏览器日志显示对象对象。有什么帮助吗?如何获得json格式的$routeparama?
谢谢。
发布于 2014-07-15 18:52:51
试着把它串起来
var json = JSON.stringify($scope.checkOutAddress);但我不确定这是不是将数据从控制器传递到另一个控制器的好方法,您可以使用提供者来存储数据。
App.provider('Data', function() {
//Properties declaration
this.tosend = '';
//Setters
this.setTosend = function(tosend) {
this.tosend = tosend;
};
//Getters
this.getTosend = function() {
return this.tosend;
};
});https://stackoverflow.com/questions/24756246
复制相似问题