The following code is part of the template file which constructs this variable URL:

<tr ng-repeat="(id, building) in buildings">
<a href="#/buildings/{{id}}">{{building.buildingNumber}}</a>


When showing the buildings using ng-repeat, we pass {{id}} to href to construct the dynamic URL. The service is pretty straightforward:

app.factory("buildingSvc", ['FIREBASE_URI', '$firebaseArray', '$firebaseObject',
  function(FIREBASE_URI, $firebaseArray, $firebaseObject) {
    var buildingsUri = FIREBASE_URI + '/buildings';
    var buildingsRef = new Firebase(buildingsUri);
    var buildings = $firebaseArray(buildingsRef);

    var getBuildings = function () {
      return buildings;

    var getBuilding = function (index) {
      var key = buildings.$keyAt(index);
      var buildingRef = buildingsRef.child(key);
      return $firebaseObject(buildingRef);

    return {
      getBuildings: getBuildings,
      getBuilding: getBuilding