Adding states from a json

Hi there,
I’m trying to get the states for my stateProvider from a json file. I found something similar for Angular-Apps at stackoverflow (http://stackoverflow.com/questions/15780269/dynamic-routing-in-angularjs-can-i-retrieve-data-from-server-before-setting-up)
So i tried to adapt this to my ionic app. but somehow the states can not be reached.


var $stateProviderReference;
var $routerProviderReference;
var database = null;
var universaldiag2 = angular.module('starter', ['ionic', 'ngCordova'])

universaldiag2.config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $urlRouterProvider) {
    $stateProviderReference=$stateProvider;
    $routerProviderReference=$urlRouterProvider;
}]);

universaldiag2.run(function($ionicPlatform, $cordovaSQLite, $http, $state) {

    $http.get('../js/routes.json').success(function(data){
        console.log("routes.json has been found");
        angular.forEach(data, function(route){
           console.log(route.id+" "+route.url+" "+route.template);
            $stateProviderReference.state( route.id, {url: route.url, template: route.template});
            console.log($state.is(route.id));
            });
        $routerProviderReference.otherwise('home');
        $state.reload();
    });
                                                
    $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }    
    //open database and create tables if they don't exist
    database= $cordovaSQLite.openDB({ name: "diag.db"});
    $cordovaSQLite.execute(database,"CREATE TABLE IF NOT EXISTS device (deviceId integer primary key, name text, manufacturer text, yob integer, serial text)");
    console.log("database succesfully created");
  }); 
});

The json-file looks like



[   
{
    "id":"home",
    "url":"/home",
    "template":"comp/home.html"
},
{
     "id":"idMan",
    "url":"/idMan",
    "template":"comp/idMan.html"
},
{
    "id":"chooseDiag",
    "url": "/chooseDiag",
    "template": "comp/chooseDiag.html"
}
]

The errormessage reads as following:

 Error: Cannot transition to abstract state '[object Object]' 

Has anyone an idea why this does not work?

cheers martin