Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading controller with no success #73

Closed
piernik opened this issue Oct 21, 2014 · 6 comments
Closed

Loading controller with no success #73

piernik opened this issue Oct 21, 2014 · 6 comments

Comments

@piernik
Copy link

piernik commented Oct 21, 2014

I'm trying to load App controller:

App
    .config(['$stateProvider', '$urlRouterProvider',
        function ($stateProvider, $urlRouterProvider) {
            'use strict';
            $stateProvider
                .state('auth', {
                    url: '/page',
                    templateUrl: 'templates/page.html',
                })
                .state('auth.login', {
                    url: '/login',
                    title: "Login",
                    templateUrl: 'templates/page/login.html',
                    controller: 'loginCtrl',
                    resolve: {
                        loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad) {
                            return $ocLazyLoad.load({
                                name: 'loginCtrl',
                                files: ['js/dev/controllers/page/loginCtrl.js']
                            });
                        }]
                    }
                })
            });

here is lognCtrl.js source:

App
    .controller('loginCtrl', function ($scope, authService) {
        console.log('asa');
    });

All I get i error: The module "loginCtrl" that you are trying to load does not exist.

How to do it well?

@ocombe
Copy link
Owner

ocombe commented Oct 21, 2014

Hi, the name should not be "loginCtrl" but the name of the module that the loginCtrl belongs to (the module name for App in your case):

return $ocLazyLoad.load({
  name: 'YourModuleName',
  files: ['js/dev/controllers/page/loginCtrl.js']
});

@piernik
Copy link
Author

piernik commented Oct 21, 2014

Works - great thanks

@ocombe
Copy link
Owner

ocombe commented Oct 21, 2014

Nice !

@ocombe ocombe closed this as completed Oct 21, 2014
@piernik
Copy link
Author

piernik commented Oct 24, 2014

Yet it's not working :/

When I added ui-bootstrap with templates I have error:

Error: [$compile:multidir] Multiple directives [alert, alert] asking for transclusion on: <div class="alert" ng-class="['alert-' + (type || 'warning'), closeable ? 'alert-dismissable' : null]" role="alert" ng-if="error" type="danger">

If I add loginCtrl without LAzyload everything is ok.

Here's my my module declaration:

var App = angular.module('infirma', ['ngAnimate', 'ui.bootstrap', 'ui.router', 'oc.lazyLoad']);

@ocombe
Copy link
Owner

ocombe commented Oct 26, 2014

Yes there is a bug here, see this issue: #78 and #71
I'll work on this asap (not until next week unfortunately, I have a very busy week coming).

ocombe added a commit that referenced this issue Nov 2, 2014
Ok so this was a really stupid mistake that was around for a long time, but that was not a problem until I changed the code to allow the reconfig...
And as often the fix is ridiculously simple! :)

Fixes #58
Fixes #71
Fixes #73
Fixes #77
@ocombe
Copy link
Owner

ocombe commented Nov 2, 2014

Fixed in 0.3.9 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants