I'm new angularjs student. I'm using state provider in my project, i don't want to change this. Because the code is done.
Here is my code:
function config($stateProvider, $urlRouterProvider) {
$urlRouterProvider 
 .when('/SecondMain', '/SecondMain/OtherPageOne')
 .when('/Main', '/Main/PageOne')
 .otherwise("/notfound")
$stateProvider
    .state('Main', {
        abstract: true,
        url: "/Main",
        templateUrl: "/templates/Common/Main.html"
    })
    .state('SecondMain', {
        abstract: true,
        url: "/SecondMain",
        templateUrl: "/templates/Common/SecondMain.html"
    })
    .state('notfound', {
        url: "/NotFound",
        templateUrl: "/templates/Common/NotFound.html"
    })
    .state('Main.PageOne', {
        url: "/Main/PageOne",
        templateUrl: "/templates/Main/PageOne.html"
    })
    .state('Main.PageTwo', {
        url: "/Main/PageTwo",
        templateUrl: "/templates/Main/PageTwo.html"
    })
    .state('SecondMain.OtherPageOne', {
        url: "/SecondMain/PageOne",
        templateUrl: "/templates/SecondMain/OtherPageOne.html"
    })
    .state('SecondMain.OtherPageTwo', {
        url: "/SecondMain/PageTwo",
        templateUrl: "/templates/SecondMain/OtherPageTwo.html"
    })
angular
    .module('inspinia')
    .config(config)
    .run(function ($rootScope, $state) {
        $rootScope.$state = $state;
    });
}
I want a logic like this: If the user put:
/Main/PageThree
This page does not exist, but the user start URL with
/Main
so that he need to go to -> /Main/PageOne
if the user put:
/Ma/PageOne
/Ma does not exist, the user starts URL totally wrong, so that he goes to -> /Notfound Basically if the user put /Main/WRONG_LINK, he go to /Main/PageOne . And if he does not start with /Main, he go to NotFound.
Can anyone help me please?
Thanks a lot!!!
 
     
     
     
    
