question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to use angularAMD with AngularUI Router? The routing in ui-router being done with $stateProvider and $urlRouterProvider (for default route).

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
marcoslincommented, Nov 5, 2013

If all you are looking for is to load controller using RequireJS syntax (i.e.: not on-demand loading), here is what you can do: https://github.com/angular-ui/ui-router/issues/479

On-demand loading should also be possible as ui-router also have a resolve property: https://github.com/angular-ui/ui-router/wiki#resolve

You should be able to do something like:

$stateProvider.state('myState', {
    resolve: {
        "__load": ['$q', '$rootScope', function ($q, $rootScope) {
                var defer = $q.defer();
                require(['myStateController'], function () {
                    defer.resolve();
                    $rootScope.$apply();
                });
                return defer.promise;
        }]
    }
});

As I do not use ui-router, I am not sure if that actually works. If you setup a simple plunker with ui-router, I can try to wire angularAMD in. Here is a very simple angularAMD plunker as an example: http://plnkr.co/edit/Pco6T6gVEEcp8IcWb4LX

0reactions
riccardoroasiocommented, Jan 28, 2016

Hi,

i’m trying to use ui-router multiple views in this way:

.state('main', { url:'/app', // abstract: true, data: {requireLogin:true }, views:{ '': angularAMD.route({ templateUrl:function (){ var token=$cookies.get('token'); return '/getTemplate/'+token+'/main'; }, controller:'' }), 'main.content@main': angularAMD.route({ templateUrl:function (){ console.log("main.content template"); var token=$cookies.get('token'); return '/getTemplate/'+token+'/main.content'; }, controller:'main.content', controllerUrl:function (){ console.log("main.content controller");var token=$cookies.get('token'); return '/getController/'+token+'/main.content.js'; }//'main.content' }),

but it seems not to work… what i’m doing wrong?

Thanks, Riccardo

Read more comments on GitHub >

github_iconTop Results From Across the Web

UI-Router for AngularJS (1.x)
UI -Router is the defacto standard for routing in AngularJS. Influenced by the core angular router $route and the Ember Router, UI-Router has ......
Read more >
angular-ui/ui-router: The de-facto solution to flexible ... - GitHub
Angular UI-Router is a client-side Single Page Application routing framework for AngularJS. Routing frameworks for SPAs update the browser's URL as the user ......
Read more >
angular-ui-router - npm
State-based routing for AngularJS 1.x. Latest version: 1.0.30, last published: a year ago. Start using angular-ui-router in your project by ...
Read more >
Routing in Angular JS using Angular UI Router - GeeksforGeeks
Angular -UI-Router is an AngularJS module used to create routes for AngularJS applications. Routes are an important part of ...
Read more >
angular-ui-router - Libraries - cdnjs - The #1 free and open ...
State-based routing for AngularJS - Simple. Fast. Reliable. Content delivery at its finest. cdnjs is a free and open-source CDN service trusted by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found