1

I am using AngularJS routing for 4 pages for example a,b,c and d but in that page there're lots of link like e,f,g,h

What I want is if I write routing condition for page then it should do routing but if any other link comes like e or f then it should redirect it to particular link like window.top.location = e because otherwise it show blank pages and search for template

app.config(['$routeProvider', '$locationProvider',
  function($routeProvider, $locationProvider) {
    $routeProvider
      .when('/a', {
        templateUrl: base_url+'a.html',
        controller: 'a'
      })
      .when('/b', {
        templateUrl: base_url+'b.html',
        controller: 'b'
      })
      .when('/c', {
        templateUrl: base_url+'c.html',
        controller: 'c'
      })
      .when('/d', {
        templateUrl: base_url+'d.html',
        controller: 'd'
      }).otherwise({
        redirectTo: LINK_IN_WHICH_USER_CLICK;
      });

    $locationProvider.html5Mode(true);
}])

now the issue is with current code is I am not getting url in which user clicked and 2nd issue is I want it to redirect like window.top.location so that it refreshed properly and don't show blank page

timtos
  • 2,225
  • 2
  • 27
  • 39
  • I'm a bit confused here, are you asking how to have angular `redirectTo` non-angular pages? because the only way that angular is going to try to route to a route in the RouteProvider is when you supply relative URLs in your `href=`. if you provide a full URL, then the RouteProvider never deals with the link at all. – Claies Jul 09 '15 at 09:06
  • Actually I have big project which have many pages and links but only 1 section requires routing so in that section I use routing but its having issue when trying to redirect on other pages which is not a part of routing but I am using angular in all pages –  Jul 09 '15 at 09:08
  • that still doesn't make sense. are the other pages each their own app then, if they aren't handled by the RouteProvider? – Claies Jul 09 '15 at 09:09
  • ok but that's how my application is working so is there any solution for situation like that ? –  Jul 09 '15 at 09:11
  • so is that a yes, the additional pages are each their own app? – Claies Jul 09 '15 at 09:11
  • yes using the different app –  Jul 09 '15 at 09:13
  • ok, so if those routes need to be handled by the server, and you must use relative URLs, and HTML5Mode, you don't have a lot of options. I'm not sure the correct syntax in this case, but I'll see what I can find. – Claies Jul 09 '15 at 09:20
  • pretty sure this will have the answer; it says "redirect outside angular".... technically, you are trying to redirect outside this angular app into another angular app, so it's appropriate in this case. http://stackoverflow.com/questions/19321765/using-routeprovider-to-redirect-to-routes-outside-of-angular – Claies Jul 09 '15 at 09:23
  • well got my answer its HTML attribute target="_self" which forcely redirect –  Jul 09 '15 at 09:44

0 Answers0