how can I pass custom data to a state from a view in ui-router?

I got it working by myself and here is how. On a controller (say: customerCtrl), you can get contact's state by name(https://github.com/angular-ui/ui-router/wiki/Quick-Reference#statename and look for $state.get([stateName]) )
Once you get the state, you can make the change you want-such as updating the custom data object's property value as follows:

//get the state by name and change the value of custom data property 
 $state.get('contacts').data.customData1= 100;
  // then you can go to that state.
 $state.go('contacts');

I hope this will help someone.


If you are trying to read custom data for the current state you can easily read it as $state.current.data.customData1 = 100;