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 …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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