Search code examples
javascriptangularjsngredux

Importing ng-redux just returns a string


I have problems importing ng-redux into my JS client app:

import ngRedux from 'ng-redux';
import needle from 'needle'; // just for debugging

console.log(`Testing: `, {ngRedux, needle});

Output from console is:

Testing: {
    needle: {version: "1.6.0", defaults: ƒ, head: ƒ, get: ƒ, post: ƒ, …},
    ngRedux: "ngRedux"
}

So needle works but ngRedux just returns a string, why?

The folder node_modules/ng-redux looks just fine.


Solution

  • It returns string, because only thing you need to do is set module as app's dependency, like this:

    import ngRedux from 'ng-redux';
    angular.module('app', [ngRedux]); // Creating "app" module
    

    If you need to get module, you can write this:

    angular.module(ngRedux); // Getting existing "ngRedux" module