Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49186

Error when trying to add new Controllers and Modules using IIFE style

$
0
0

@bgadiel wrote:

Hi,
I am trying to add new modules and controllers using gulp-inject.
Problem is that I get an error when I adding new modules / controllers in IIFE:

ionic.bundle.js:13438 Uncaught Error: [$injector:nomod] Module 'app.home' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

// app.js

(function () {
  'use strict';
angular.module('app', ['ionic', 'app.home'])
.run(function($ionicPlatform) {....... }

// home.module.js

(function () {
'use strict';
angular.module('app.home', []);
})();

// home.controller.js

(function () {
'use strict';
angular.module('app.home')
.controller('HomeController', HomeController);
function HomeController() {
...........
})();

Only if I remove the IIFE from home.controller.js and declare the module in the controller file the error does not show.

angular.module('app.home', [])
    .controller('HomeController', HomeController);

Is this the only way of adding new modules to ionic app?

Thanks.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>