Closed JoeGrasso closed 9 years ago
I am assuming you are saying that you wish to lazy load routes. In that case, I suggest you look at:
http://christopherthielen.github.io/ui-router-extras/#/future
If not, please provide more specific examples. I for one cannot figure out why anyone would want to define the route in app.run.
IN THE REAL WORLD, some users may not have access to certain routes. IN THE REAL WORLD, one would want the routes to be dynamic and populate during the app.run method.
I cannot and have not seen any angularAMD examples where lazy loading is performed where the routes are dynamic and populated in the app.run call. I can do this without angularAMD, but so far no examples of this with angularAMD.
@JoeGrasso indeed are interesting points. I eagerly awaits your sample project. This is the beauty of open source projects: everyone gets to contribute.
Closing due to no reply from user. Continue to await a REAL WORLD sample from @JoeGrasso.
@JoeGrasso Use angularAMD.config('Config', {...})
in a separate file used for Config, and then it will be loaded into your app.js before the app.run(...)
is called. In terms of "some users may not have access to certain routes", you can do something like this:
app.config(function ($routeProvider) {
$routeProvider
.when('/users/dashboard', angularAMD.route({
templateUrl: 'users/dashboard.html',
controller: 'DashboardController',
access: 'members'
}));
Then intercept the route requests, and if current route has access == "members"
, test that the user is authenticated. If the users isn't authenticated, redirect them to the login page:
app.run(function ($rootScope, $location) {
$rootScope.$on('$routeChangeStart', function (event, next, current) {
//code to test if user has authentication
});
});
I tried to use AngulareAmd, but the examples are just too overly simplified.
Case in point. I wanted to use dynamic routes that would be called in app.run. I can do it w/o require/amd. But when I try the same thing using require/amd, nothing works.
And what resource can I go to for help? Well unless I really, really, really need to do a 'Hello World', ie nothing real, I am out of luck.
Who hard codes routes in a real world app ?!?!?!?!