So for instance I might have a stage as described:
.state('room', {
url: "/room/:id",
templateUrl: "app/views/room.html",
controller: 'roomsCtrl'
})
And then a controller as defined:
angular.module('app')
.controller('roomsCtrl', ['$scope','Room', function ($scope,Room) {
$scope.rooms = Room.get({id: 1}, function(item) {
});
console.log($scope);
}]);
In this instance Room is a service object that has been hooked up to a restful api. I would like to test to see if id is present within the controller and pass that to the id parameter "Room.get({id: 1}" if it exists otherwise pass nothing.
How would one retrieve the parameter id which would be present within the url?
In my case it shows up like: /#/room/1
Here is an example of some html from my view with a link that will key up to the id:
<a ui-sref="room({ id: '1' })">
{{room.name}}
</a>