Skip to content

Instantly share code, notes, and snippets.

@sdebaun
Created January 2, 2014 22:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sdebaun/8228348 to your computer and use it in GitHub Desktop.
Trying to figure out how to have ui.route with stateParams and angularfire bindings work together. I have a list controller that shows a list of games. The html elements in that list should use ui-sref to provide a link to the detail state for a given game. The problem: I am trying to get a game's key so that I can tell the detail state to look …
# in my app config, the route...
.state 'games.list',
url: '/list'
controller: "GameListControl"
.state 'games.detail',
url: '/detail/{gameId:.*}'
controller: "GameDetailControl"
# fb.* methods are from my custom factory
# fb.link returns a $firebase link
# the detail controller
.controller( 'GameDetailControl', ['$scope','fb', ($scope,fb) ->
$scope.game = fb.link(fb.root.child('games').child($scope.auth.user.id).child($scope.$stateParams.gameId))
])
# the list controller
.controller( 'GameListControl', ['$scope','fb', ($scope,fb) ->
$scope.games = fb.link(fb.root.child('games').child(user.id))
])
Snippet from the list controller html
<ul>
<li ng-repeat="game in games">
<a href='#' ui-sref="games.detail({gameId: WHERE_DO_I_GET_KEY_NAME_FOR_GAME})">{{game.name}}</a>
</li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment