I currently have a good working static version of my question being asked. The issue is that I can't seem to format the JSON properly when trying to use $StateProvider in a loop. I'm not sure exactly what part isn't being formatted properly causing an "undefined is not a function" error. But below is my working static State definition with views and resolved using $ocLazyLoad. This works, really not sure why my JSON version version in a loop does not?
Working Static Version - THIS DEFINITELY WORKS FOR ME
// ABSTRACT APP LAYOUT - VIEW THAT DEFINES ENTIRE LAYOUT STRUCTURE
$stateProvider
.state('app', {
abstract: true,
controller: 'LayoutCtrl',
templateUrl: 'app/components/core/layout/layout.html'
});
// VIEWS
// CURRENT LAZY LOADING WAS REFERENCED FROM HERE - https://egghead.io/lessons/angularjs-lazy-loading-modules-with-ui-router-and-oclazyload
$stateProvider
.state('app.dashboard', {
views: {
'feature': {
templateUrl: 'lazyload/components/core/features/dashboard/dashboard.html',
controller: "DashboardCtrl as dashboard",
resolve: {
dashboard: function ($ocLazyLoad) {
return $ocLazyLoad.load(
{
name: "dashboard",
files: ["lazyload/components/core/features/dashboard/dashboard-controller.js"]
}
)
}
}
}
}
})
.state('app.other-feature', {
views: {
'feature': {
templateUrl: 'lazyload/components/core/features/other-feature/other-feature.html',
controller: "OtherFeatureCtrl as otherFeature",
resolve: {
otherFeature: function ($ocLazyLoad) {
return $ocLazyLoad.load(
{
name: "otherFeature",
files: ["lazyload/components/core/features/other-feature/other-feature.js"]
}
)
}
}
}
}
});
I'd like to be clear, the static version does work, it's the looped version I can't seem to get working. Perhaps I'm not doing some kind of array notation for the function properly or something? Any help is greatly appreciated!