Ui-Router with Model Data

Using Angular, Ionic and UI-Router, I am trying to change states and pass data to State Params. With Angular built into Ng-Route, it was easy, but just created the link that way.

<a href="state2/{{detail.id}}">Brings me to state 2 with detail about this item</a>

But as Ionic switched to UI-Router, this tends to disrupt the created transitions. I saw a demo where in people controllers there is a click handler that sets a state change:

      $scope.switchState = function(){
        $state.go('abstract.main'); 

        <a ng-click="switchState">Change States</a>

This works if the nested state is only a static representation. But I want to know how to properly change states and go through the parameters to get the data. Any ideas?

+3
source share
1 answer

For example, for this state:

.state('test', {
    url: '/test/:id',
    templateUrl: 'insertpathhere.html'
})

:

$state.go('test', { id: 420 });

- html:

<a ui-sref="test({id:detail.id})">Click me</a>
+5

All Articles