Resolving an object in u-router state with ui-sref

Having a really big JSON object in the Angular controller and ui-sref link, I want to pass this object to the template controller, which will be in the u-view.
I know that I can pass parameters for the state using ui-sref, but I do not want this object to appear in the address bar. In addition, I know that we can use the โ€œallowโ€ parameter in the state, but I canโ€™t find a way to pass data to the โ€œallowโ€ function from the link. <b> Update
If I use $ state.go like this:
Router configuration

state('social.feed.detailed', url: '/:activityID' templateUrl: 'views/social/detailedactivity.html' ) 

in the template

 <ums-social-activity ng-repeat="record in SOC_FEED_CTRL.records" activity="record" ui-sref-active="selected" ng-click="SOC_FEED_CTRL.goToDetailed(record)"> </ums-social-activity> 

in the controller

 $scope.SOC_FEED_CTRL.goToDetailed = (activity) -> # here activity is real object $state.go('social.feed.detailed', {'activityID':activity.id, 'activity':activity}) 

Then the parameter "activity" is not eliminated at all.
Update 2
If I change the route configuration to this:

 state('social.feed.detailed', url: '/:activityID?activity' templateUrl: 'views/social/detailedactivity.html' ) 

Then the operation is the string "[object Object]"

+8
javascript angularjs angular-ui-router
source share
2 answers

You can use the ui-router module $state.go function call to manually pass $stateParams , which will not be displayed in the url. Thus, instead of using the ui-sref you should install an ng-click handler that calls $state.go(STATE,{'param':JSON}) .

Then enter $stateParams into your controller and read

 $stateParams.param 

To return a JSON object.

+2
source share

Likely,

  ui-sref-active="selected" 

Selected represents an object

 selected.name 

or

 selected.id 

The chosen one looks like it is a key value relationship. In any case, this is what I am experiencing.

 <a ui-sref="itinerary.name({name:person.id})"> 
+1
source share

All Articles