Problem with ui-sref

Asked

Viewed 98 times

0

I’m having trouble making a POST using ui-sref. I need to call a controller passing an ID where it will return me the recorded data in the database. Works great when using route, but when I use ui.route I’m having trouble.

With ngRouter

.when("/highways/:id",
        {
            templateUrl: "assets/templates/highway/edit.html",
            controller: "HighwayController",
            controllerAs: "ctrl"
        })

With ui.router

.state('highways.id', {
        url: '/:id',
        templateUrl: 'assets/templates/highway/edit.html',
        controller: 'HighwayController as ctrl'


    })

Call in html

<tr ng-repeat="hw in ctrl.search.results" ui-sref="highways.id(hw)">
    <!--ng-click="ctrl.search.redirectToItem(hw)"-->

This ng-click is the call that was working before using ui.router.

1 answer

2

Please try it this way:

<tr ng-repeat="hw in ctrl.search.results" ui-sref="highways.id({id: hw})">
  • I did, but it does not call the other template where the data should be loaded.

  • Is there any configuration that needs to be done within $state Highway.id ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.