How to pass object with ui router between controllers in a $state angularjs -


I'm using.

I have my user module:

  is required ('angular / angular'); Required ('angular-ui router'); Angular.module ('usermodule', ['ui.router']) .config (['$ stateProvider', function ($ state provider) {$ stateProvider .state ('utenti', {url: '/ utenti', templateUrl : 'Src / utenti / views / utenti.tpl.html', Controller: 'RegistrationCurrent',}) .state ('access', {url:' / access', templateUrl: 'src / utenti / views / access.tpl Controller: 'AccessCtrl',});}]). Controller ('registrar', is required ('./controllers / registration login')) Controller ('AccessCtrl' is required ('./controller / access'));  

In my registration, I use a service to create a new member:

  module.exports = function ($ scope, user, subscriber) , $ State, $ location, $ rootsecope, $ state params) {$ scope.registration = function (form) {if (form! $ Valid) {console.log ('input error'); Return; } Else {console.log ('valid form'); Member. Create ($ scope.newMember, function (data) {$ state.go ('access', data);}, function (data) {console.log (data);}); }}; };  

I would like to use that data in my next view related to accessctl. I do not want to use the ID in my URL and I want to use the $ state parameter

My access controller is:

  module.exports = function ($ scope, user, member, $ state, $ root sssp, $ state) {console.log ($ state); Console.log ($ stateParams); };  

In that console. I did not find my object with the $ State. Ago.

You can pass data near $ states to the next view Add the ultimate in the target route

$ stateProvider .state ('utenti', {url: '/ utenti', templateUrl: 'src / utenti / views / utenti.tpl.html', Parameters: {MyParam: null}, Controller: 'Datacroll',})

Pass data for the next view

  $ state.go ("utenti", {MyParam: {"Data" : "Data"}})  

and get data in the next controller

  $ scope.paramDetails = $ stateParams.myParam;  

Comments