1

I have a route provider defined:

$routeProvider.when('/interview', {
    controller: 'Interview',
    templateUrl: function(parms) {
    return parms.target + '/partials/Interview.html';
    }
});

But I get the following exception:

Uncaught TypeError: Object function (parms) {
                   return 'partials/Interview.html';
                } has no method 'match'

With breakpoints, I found that AngularJS thinks my function is an URL.

Completely confused.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
user2938828
  • 91
  • 1
  • 1
  • 5
  • See this: http://stackoverflow.com/questions/11534710/angularjs-how-to-use-routeparams-in-generating-the-templateurl – jbenowitz Oct 30 '13 at 20:49

1 Answers1

1

You're probably using an the stable version (1.0.8) of angular which doesn't allow for templateUrl to be a function. You should give it a shot with the latest release candidate, 1.2-rc3.

1.0.8 documentation for $routeProvider:

templateUrl – {string=} – path to an html template that should be used by ngView.

1.2-rc3 documentation for $routeProvider:

templateUrl – {string=|function()=} – path or function that returns a path to an html template that should be used by ngView.

If templateUrl is a function, it will be called with the following parameters:

{Array.} - route parameters extracted from the current $location.path() by applying the current route

John Ledbetter
  • 13,557
  • 1
  • 61
  • 80