Skip to content

Instantly share code, notes, and snippets.

@kubakrzempek
Created April 16, 2015 12:58
Show Gist options
  • Save kubakrzempek/0b34accff3c331d9f808 to your computer and use it in GitHub Desktop.
Save kubakrzempek/0b34accff3c331d9f808 to your computer and use it in GitHub Desktop.
angular & friendly urls
angular.module('merckUnite').controller 'questionCtrl', ($scope, $state, $stateParams, Questions) ->
$scope.id = $stateParams.id
Questions.single($scope.id).success (data) ->
$scope.question = data
if $scope.question.slug != $stateParams.slug
$state.go('question',
{
id : $scope.question.id,
slug: $scope.question.slug,
},
{
location: 'replace',
inherit: false,
notify: false
}
)
$stateProvider
.state('question',
url: "/questions/:id/:slug"
params: {
slug: {
value: null,
squash: true
},
}
templateUrl: "single-question.html"
modals: ['login', 'register', 'profile']
controller: "questionCtrl")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment