0

I have an app made with Angular (angular 1.6) and NodeJS, and I can't import the angular library ngResource into my app. These are the steps I did:

1: in command line I input npm install --save angular-resource

2: in app.js:

import angular from 'angular';
import ngResource from 'angular-resource';
import uiRouter from 'angular-ui-router';
import Components from './components/components';



angular.module('myApp', [
  uiRouter,
  Components,
  ngResource
])
.component('homePage', HomeComponent)
.service('AirportsService', AirportsService)
.service('CheapFlightService', CheapFlightService)

and after doing that, I get this error in the browser:

angular-resource.js:444 Uncaught TypeError:

angular.module(...).info is not a function

Vignesh
  • 1,045
  • 2
  • 17
  • 34
Captain
  • 105
  • 1
  • 15
  • I think you should use @NgModule() instead of angular.module. angular.module is from angular1 and I am not sure that function still available in angular 4. – Vignesh Dec 11 '17 at 07:41
  • 1
    Hi Vignesh, I am using angular 1.6 to this project – Captain Dec 11 '17 at 07:55
  • can you post your index.html code? I don't remember using import statements with angular1 but it's been a lot of time since I worked in it. I am not sure whether the syntax above is right for angular1. post your index.html as well to get more info. – Vignesh Dec 11 '17 at 09:02

1 Answers1

0

Looks like you are running into compatibility problem with angularjs 1.6.x modules.

Make sure the angular and the associated modules are of same version in package.json.

With angular@1.6.7 and angular-resource@1.6.7, the angular1 components does work fine for me.