For anyone interested, I found the answer to this. It is demonstrated in John's gulp-patterns repository, here <https://github.com/johnpapa/gulp-patterns>.
On Friday, January 23, 2015 at 12:20:09 PM UTC+1, Dan Cancro wrote: > > Hi group, > > I would like to > 1) maintain separate route/state configuration files for each functional > module according to John Papa's styleguide > <https://github.com/johnpapa/angularjs-styleguide#style-y271> > 2) give states special properties because that's what John Papa did in > his Pluralsight Angular with Breeze course > <http://pluralsight.com/training/courses/TableOfContents?courseName=build-apps-angular-breeze>. > > And it just seems reasonable that an app would put special properties on > states. > > > However, in the course I see that all of the routes for the whole app are > defined in a single file, config.routes.js. > > The code has three steps: > 1) The routes are defined in an array with special properties (title, > settings, nav, content). > function getRoutes() { > return [...] > 2) The array is stored as an Angular constant > app.constant('routes', getRoutes()); > 3) This Angular constant is iterated through to set the routes > routes.forEach(function (r) { > $routeProvider.when(url, definition); > } > > Then the Angular constant, "routes", is used later elsewhere in the app. > > > So I tried this: > 1) Define states for each module in a separate array in a file for the > module and concatenate that array onto a growing array property of > angular.module("app") > 2) In the app.js file, create an Angular constant and set it to this array > 3) Iterate through this to set the states using $stateProvider.state() > calls in a single app.config() call > > This didn't work, seemingly because app.coffee was processed before the > individual module route files and so the array was undefined at the time of > the .state() calls. > > > Then I tried this: > 1) Define states for each module in a separate array in a file for the > module > 2) After each module's state definitions, call app.config with a call to a > method, setModuleStates, of a factory, stateSetter, that 1) concats them to > a growing array of all states for the app and 2) calls $stateProvider.state > > This didn't work because the stateSetter factory was unknown at the point > it was injected, or more likely because I still don't quite understand how > to handle injectables and parameters in function signatures. > > > > > mymodule.coffee: > moduleStates = [...] > angular.module 'app' > .config (stateSetter) -> > stateSetter.setModuleStates(moduleStates) > > > > > app.coffee: > .factory 'stateSetter', ($stateProvider) -> # $stateProvider > is an injectable > > setModuleStates = (moduleStates) -> # moduleStates is > a parameter > setState = (url, definition) -> # url and > definition are parameters > ... > $stateProvider.state slashModule + definition.title, > > app.appStates = angular.module('app').appStates or [] > app.appStates.concat(moduleStates) > moduleStates.forEach (r) -> > setState r.url, r.config > > > > So I'm stumped. The generator-angular-fullstack states are modularized > into distinct files for each module, but there's no additional Angular > constant to hold all of them and no special properties tied to them. This > seems to make it tricky. How do you do this? > > Thanks, > Dan > > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
