Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49164

Href works but ui-sref says "could not resolve state"

$
0
0

@cmaronchick wrote:

I'm sure I did something basic in my setup that's causing this problem, but I haven't been able to resolve this issue.

I have a list of exercises to which I want to link to their details (though I think I'll rewrite to display in-line, but that's for another day). When I use href, it works fine, but ui-sref gives me a "could not resolve state /exercise/:id from exercises"

Here's my app.js:

 .config(function($stateProvider, $urlRouterProvider) {
 // Ionic uses AngularUI Router which uses the concept of states
 // Learn more here: https://github.com/angular-ui/ui-router
 // Set up the various states which the app can be in.
 // Each state's controller can be found in controllers.js
 $stateProvider

.state('exercises', {
  url: '/exercises',
  templateUrl: 'templates/exercises.html',
  controller: 'exercisesCtrl'

})
.state('exercises.detail', {
  url: '/exercise/:exerciseId',
  templateUrl: 'templates/exercise.html',
  controller: 'exerciseCtrl'
})
.state('timer', {
  url: '/timer/:id',
  templateUrl: 'templates/timer.html',
  controller: 'tmrControl'
});
$urlRouterProvider.otherwise('/exercises');
});

Here is the code from my template:

<ion-list>
<ion-item
class="item-icon-right"
      ng-repeat="exercise in exercises track by exercise.id"
      ui-sref="exercises.detail/:exercise.id">
      {{ exercise.id }} | {{ exercise.name }}
      <i class="icon ion-ios-arrow-forward icon-accessory"></i>
      <ion-option-button class="button-assertive" ng-click="deleteExerciseListItem($index)">
        Remove
      </ion-option-button>
    </ion-item>
</ion-list>

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49164

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>