I've been stuck for about a day on a problem that I can't see through.
I have the following code in a users.js.coffee file:
app = angular.module("app", ["ngResource"])
app.config ['$routeProvider', '$locationProvider', ($routeProvider, $locationProvider) ->
$locationProvider.html5Mode(true)
$routeProvider.when('/users/:id', {templateUrl: '/users/:id.json', controller: UserCtrl})
$routeProvider.when('/users/:id/videos', {templateUrl: '/users/:id/videos.json', controller: UserCtrl})
]
app.factory "User", ["$resource", ($resource) ->
$resource("/users/:id", {id: "@id"}, {
show: {method: "GET"},
videos: {method: "GET", isArray:true}
})
]
@UserCtrl = ["$scope", "$location", "$route", "http", "$routeParams", "User", ($scope, $location, $route, $http, $routeParams, User) ->
console.log($location)//LocationUrl {$$parse: function, $$compose: function, $$rewriteAppUrl: function, $$protocol: "http", $$host: "localhost"…}
console.log($route)//Object {routes: Object, reload: function}
console.log($routeParams)//Object {}
]
Why would $routeParams be an empty object? If I call $route.current.params in a view, it shows the appropriate parameters. But not in the controller. What's more, I can't call $route.current.params in the controller, because "current" isn't yet defined.