[英]How can I pass json object from one page to another page
I'm trying to pass a json object just after redirecting to another page, The problem is when I use $scope.data in order to save client, the problem is that after making the redirection the $scope.data is empty again 我试图在重定向到另一个页面之后传递一个json对象,问题是当我使用$ scope.data来保存客户端时,问题是在进行重定向之后,$ scope.data再次为空
testProjectApp.controller('ClientController',
function EventController($scope, clientList, $window, updateClient){
$scope.editClient=function(client){
$scope.data=client;
$window.location.href = 'ClientDetails.html";
}
the controller is working on two pages 控制器在两页上工作
It depends on if you only want to use angular specific APIs or general methods are also acceptable. 这取决于您是否只想使用特定于角度的API或可接受的常规方法。 Consider the followings, which one better fits your situation, you may need to serialize/de-serialize the json object: 考虑以下内容,它更适合您的情况,您可能需要序列化/反序列化json对象:
Some options: 一些选项:
get
, set
基本上是get
, set
It would be a good idea to figure out the size of the json, and are there any limits and constraints first, then choose the suitable method. 弄清json的大小是一个好主意,首先要有任何限制和约束,然后选择合适的方法。
Angular is used for SPA's - single paged applications. Angular用于SPA-单页应用程序。 As soon as you redirect to another page, a new scope is created. 一旦您重定向到另一个页面,就会创建一个新的作用域。 I used local storage - here I asked and answered my question in reference to it - AngularJS help sharing data between controllers using $broadcast 我使用了本地存储-在这里我参考并询问了我的问题-AngularJS使用$ broadcast帮助在控制器之间共享数据
So to be honest, this is a duplicate. 老实说,这是重复的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.