Monday, December 23, 2013

Angular And Firebase Routing and Small Data Sets

I was learning how to use Firebase with Angular recently, and I ran into a problem, when I asked a question on stack overflow I received an answer basically saying to call firebaseurl/ of the data, well I can get the index, but I wasn't sure how my second controller could get that data ( so when my router swapped to the new page, I didn't know how to get it). Thanks to a generous soul at Open Hack last night, we discovered $routeParams, apparently when you use :id in your router config, when you use $routeParams in your "new" controller, you can access whatever that : was, so in this case $routeParams.id gave me the id, which is precisely what I needed. 

I just wanted to point this out in case anyone else had issues. So long story short,

First Page had this:
<a href="http://www.blogger.com/blogger.g?blogID=4424951240484003947#/blah/{{index}}">Blah </a>(Where index is my id)

the router config looked like this

path="/blah/:id"

the "new controller" added a reference to $routeParams (like where we reference firebase, just add a comma and go).
Then I did

"firebaseurl" + $routeParams.id to capture a smaller set of data.