My app.run:
app.run([ '$q', '$rootScope', '$state', 'settings', 'datacontext', function ($q, $rootScope, $state, settings, datacontext) { settings.currentLang = settings.languages[0]; breeze.core.extendQ($rootScope, $q); datacontext.getSideMenuItems().then(function (data) { var startUp = undefined; var rootUrl = '/app/views/'; /// this is the upper level used for side menu only angular.forEach(data, function (value) { // now loop thru the data for the $state items angular.forEach(value.viewStates, function (viewState, key) { if (key == 0) { startUp = viewState.name; } var state = { "url": '/' + viewState.name, "parent": viewState.parentName, "abstract": viewState.isAbstract, "views": {} }; angular.forEach(viewState.views, function (view) { state.views[view.name] = { controller: view.controllerName, templateUrl: rootUrl + view.templateUrl + '.html' }; }); $stateProviderRef.state(viewState.name, state); }); $state.go(startUp); }); }); }
My details: [as a JSON representation, ignore capitalization, breeze renames them lowercase]
[{ "$id": "1", "Id": 2, "Icon": "fa-home", "IsActive": "active", "IsShared": false, "OrderNum": 1000, "Title": "Dashboards", "FK_DbModuleId": 1, "DBoardModule": null, "ViewStates": [ { "$id": "2", "Id": 2, "IsAbstract": false, "Name": "PersDboards01", "ParentName": "root", "OrderNum": 1, "FK_ViewGroupId": 2, "ViewGroup": { "$ref": "1" }, "Views": [ { "$id": "3", "Id": 4, "ControllerName": "MyDashboardCtrl", "Name": "container@", "TemplateUrl": "dashboards/myDashboard", "FK_ViewStateId": 2, "ViewState": { "$ref": "2" } }, { "$id": "4", "Id": 5, "ControllerName": "LeftPanelCtrl", "Name": "leftPanel@", "Title": "null", "TemplateUrl": "shell/html/left-panel", "FK_ViewStateId": 2, "ViewState": { "$ref": "2" } } ] } ]
I know that Json has uppercase properties, but I do not use JSON, I just copied this from a violinist who got it from my web API.
I understand that the error "Unable to read the" navigable "property from undefined" means that I do not define the child state after determining the parent state, but I do not see where I do it.
Does anyone know a better way to structure app.run?
UPDATE:
I found my mistake, see below.