0

Hi below is my code for urlRouterProvider otherwise.

.config(function config($urlRouterProvider, $stateProvider) { $urlRouterProvider.otherwise('/invalid'); $stateProvider.state('view', { url: '/view?{businessId:^[0-9]{1,20}$}', templateUrl: 'view/view.tpl.html', controller: 'ViewCtrl', controllerAs: 'vm' }) .state('otherwise', { url: '/invalid', templateUrl: 'view/view.error.tpl.html' }); }) 

This is what i am expecting: 1. if i go to view?businessId=12345 it should load the page without any issues 2. if i go to view?businessId=abcd it should re-direct it to the view.error.tpl.html

But instead, it does nothing if i enter the invalid url. I reffered to this post for help but none of the options really work Otherwise on StateProvider

2 Answers 2

2

you can try this, without using the otherwise function:

$stateProvider.state('view', { url: '/view?{businessId:^[0-9]{1,20}$}', templateUrl: 'view/view.tpl.html', controller: 'ViewCtrl', controllerAs: 'vm' }) .state('otherwise', { url: '*path', templateUrl: 'view/view.error.tpl.html' }); 
Sign up to request clarification or add additional context in comments.

Comments

0

Try this

.config(function ($urlRouterProvider, $stateProvider) { $stateProvider.state('view', { url: '/view?{businessId:^[0-9]{1,20}$}', templateUrl: 'view/view.tpl.html', controller: 'ViewCtrl', controllerAs: 'vm' }) .state('otherwise', { url: '*path', templateUrl: 'view/view.error.tpl.html' }); }) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.