Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I have followed the instructions from https://github.com/angular-ui/ui-router/wiki/URL-Routing but cannot get this to work properly.

I have the following:

var application = angular.module('application', ['ui.router']);

application.config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.otherwise("/test");

$stateProvider
    .state('index', {
        url: "/test/:param",
        templateUrl: "App/Test.html", 
        controller: function ($scope, $stateParams) {
            alert($stateParams.param);
        }
    });   

$locationProvider.html5Mode(true);
});

Without the /:param this works as you would expect - i.e. the ui-view is correctly populated with Test.html. However, whenever I put the /:param in I get an error. The error is:

GET http://localhost:3880/test/App/Test.html 404 (Not Found)

App is the route of my angular stuff and Test.html should have a path of

http://localhost:3880/App/Test.html 

which it does if not trying /:param. However, when trying /:param you can see that there is an extra /test/ in the path before /App.

Please someone help, as I would like to consume the parameter in the controller once it is correct.

share|improve this question
    
no answers so far ? @Shumii – mavis Feb 17 at 5:40
    
@mavis no - but I used a BaseUrl to get around it. Then I upgraded angular which removed the need for the BaseUrl. In short the problem does not exist for me anymore - although I can not be sure enough to give a conclusive answer. – Shumii Feb 17 at 9:01

2 Answers 2

Use absolute path for templateUrl. relative url wont work.

templateUrl: "/path/to/App/Test.html",
share|improve this answer

You URL for this route should be like this : http://localhost:3880/test/app Where app is param.

share|improve this answer
    
Yes, that is the url I am trying to go to.... but I get the error as mentioned which is the problem. – Shumii Jun 22 '14 at 6:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.