user4191537
user4191537

Reputation: 213

UI-router redirect to different url?

This might not even be possible, but I'm going to try anyway. In my website I have a couple of states defined with ui-router. One of these states should link to another domain. Is this possible?

$stateProvider
  .state('index', {
    url: "/index",
    templateUrl: "views/home.html",
    controller: "MainController",
    ncyBreadcrumb: {
        label: 'Home'
    }
  })
  .state('about', {
    url: "/about",
    templateUrl: "views/about.html",
    controller: "AboutController",
    ncyBreadcrumb: {
        label: 'About',
        parent: 'index'
    }
  })
  .state('Us', {
    url: "/us",
    parent: "about",
    views : {
      '@': {
        templateUrl: 'views/us.html',
      },
    }
  })
  .when('contact', 'http://www.example.com')

Upvotes: 1

Views: 1848

Answers (1)

Asik
Asik

Reputation: 7977

UI router is handling internal application URL's. anyway you can achieve using script redirection.

$stateProvider.state('contact', {
     url: '/',
     template: 'Redirecting...<script>window.location="http://www.example.com"</script>'
});

Upvotes: 3

Related Questions