0

I have the following problem: I am using ng-admin to build an administration page. There is a custom page added to the ng-admin interface. The standard ng-admin pages are routed by ng-admin and there is no problem with the list/edit views. Now I want to use the angular.js routing for the custom page because I need an url routing with parameters in the url. The routing does works if I don't use any parameters in the url. Once I use the parameters the routing for the custom page does work but when I click any other page the new page is loading forever and not opening. If I use a routing without parameters all pages are loading correctly.

This is working:

function routing($stateProvider, $urlRouterProvider){
// default route
  $urlRouterProvider.otherwise('/custom');
  $stateProvider.state('custom', {
    parent: 'main',
    url: '/custom',
    template: customTemplate,
    controller: 'CustomController'
    });
}

This is not working:

function routing($stateProvider, $urlRouterProvider){
// default route
  $urlRouterProvider.otherwise('/custom');
  $stateProvider.state('custom', {
    parent: 'main',
    url: '/custom?date',
    template: customTemplate,
    controller: 'CustomController'
    });
}

I use the $state.go function to change the states and route the page:

function transition(){
  var dates = $scope.startdate.getTime();
  $state.go('custom', {date: dates}, {notify: false});
};
mmargo
  • 31
  • 1
  • 5

1 Answers1

0

I believe you may have to declare the parameters in a params section:

function routing($stateProvider, $urlRouterProvider){
  // default route
  $urlRouterProvider.otherwise('/custom');
  $stateProvider.state('custom', {
    parent: 'main',
    url: '/custom?date',
    params: { date: null },
    template: customTemplate,
    controller: 'CustomController'
  });
}

See the ui-router docs for details.

François Zaninotto
  • 7,068
  • 2
  • 35
  • 56