Of course, if you pass parameters that are not reflected in the URL, the parameters will not be available during operations such as going back.
You can use @whosesmile's method to operate. Use service. LZ can take a look at angular's built-in $cacheFactory. 使用这个可以生成一个缓存, 执行put get remove removeAll and other operations
Usually two options
1. Global variables, that is, using $rootScope
2. Use service. Because service is a single instance and will not be destroyed, you can define a general cache data service to access data. Call service.set(key, value) in the controller that needs to transfer data. When needed Call service.get('key')
Not only can you pass simple strings, but of course you can also pass objects
The name of the parameter in the router configuration. Take ui-router as an example
Use $state for page switching
Use $stateParams in controller to get parameters
Of course, if you pass parameters that are not reflected in the URL, the parameters will not be available during operations such as going back.
You can use @whosesmile's method to operate. Use service. LZ can take a look at angular's built-in
$cacheFactory
. 使用这个可以生成一个缓存, 执行put get remove removeAll
and other operationshttp://stackoverflow.com/a/25999849/2586541
Usually two options
in the controller that read the previous data1. Global variables, that is, using $rootScope
2. Use service. Because service is a single instance and will not be destroyed, you can define a general cache data service to access data. Call service.set(key, value) in the controller that needs to transfer data. When needed Call service.get('key')
I forgot which version ui-router added the following method to maintain the parameters in the url
1.$state
2.Configure router
3. Use $stateParam.datas to get