1

i use ui-router for nested routing in angularjs, it works fine but there is a problem, when i refresh the page or enter the url manually and directly, i get an error: The requested URL /home/general was not found on this server. my app code is:

angular.module("app",["ui.router"])
.controller("appController",["$scope", function($scope){}])
.config(function($stateProvider, $urlRouterProvider,$locationProvider){
        $stateProvider
            .state('home', {
                url: "/",
                templateUrl: "/library/ngTemplates/home.html"
            })
            .state('home.general', {
                url: "home/general",
                templateUrl: "/library/ngTemplates/home-general.html"
            })
            .state('home.lifeStyle', {
                url: "home/life-style",
                templateUrl: "/library/ngTemplates/home-life-style.html"
            })
            .state('home.lifeStyle.sport', {
                url: "/sport",
                templateUrl: "/library/ngTemplates/home-life-style-sport.html"
            })
            .state('home.lifeStyle.economic', {
                url: "/economic",
                templateUrl: "/library/ngTemplates/home-life-style-economic.html"
            });
            $locationProvider.html5Mode(true);
});
6
  • Thats because you dont add this route. Add $urlRouterProvider.otherwise("/") to the config and test again please. Commented Dec 14, 2014 at 14:17
  • See stackoverflow.com/questions/22735026/… Commented Dec 14, 2014 at 14:24
  • 2
    where is ur state declaration for purchase-help? Commented Dec 14, 2014 at 14:53
  • Here is the FAQ link stackoverflow.com/questions/22735026/… with all the details how to settle UI-Router on the server. If server is properly set, all is working - check the working example here Commented Dec 14, 2014 at 16:08
  • i added $urlRouterProvider.otherwise("/") but still not working Commented Dec 15, 2014 at 6:24

1 Answer 1

1

You should change

url: "home/general"

to

url: "/home/general"

That first backlash is what's holding your routing back.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.