J
J
jenya77712016-12-07 23:48:02
Angular
jenya7771, 2016-12-07 23:48:02

How to setup ui router?

How to set up transitions in ui route so that only certain values ​​can be set for course, for example 1, 2, 3 , and all others are not?

.state('home.listgroup', {
    url: ':course/:grouplist',
    templateUrl: 'templates/listgroup.php',
    controller: 'listGroupCtrl'
  })

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nicholas, 2016-12-08
@healqq

1. option - regexp, for example:

.state('home.listgroup', {
    url: ':course/{grouplist:[1-3]}',
    templateUrl: 'templates/listgroup.php',
    controller: 'listGroupCtrl'
  })

Option 2 - do something in resolve, for example, load data and return reject for incorrect data:
.state('home.listgroup', {
    url: ':course/:grouplist',
    templateUrl: 'templates/listgroup.php',
    controller: 'listGroupCtrl',
    resolve: ['$q', '$stateParams', function($q) {
         if ($stateParams.grouplist > 3) {
             return $q.reject();
         }
    })];
  })

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question