1

I'm started learning ionic 2 and I have a problem with importing dependency in my app.ts file.

when i want use:

"import {Http} from "angular2/http";

its show me, error with this subject:

[ts] cannot find module 'angular2/http'.

this is my package.json's content:

"dependencies": {
"@angular/common": "^2.0.0-rc.1",
"@angular/compiler": "^2.0.0-rc.1",
"@angular/core": "^2.0.0-rc.1",
"@angular/http": "^2.0.0-rc.1",
"@angular/platform-browser": "^2.0.0-rc.1",
"@angular/platform-browser-dynamic": "^2.0.0-rc.1",
"@angular/router": "^2.0.0-rc.1",
"es6-shim": "^0.35.0",
"ionic-angular": "2.0.0-beta.7",
"ionic-native": "^1.1.0",
"ionicons": "3.0.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12"
}

2 Answers 2

5

ok, i found a solution,

in Ionic 2, Beta 7, we should use:

import {Http} from '@angular/http';

Sign up to request clarification or add additional context in comments.

Comments

4

Just in case if this could be useful to someone, there are some other changes you would need to do in order to upgrade to Ionic 2 beta 7 (or beta 8 now).

You can take a look at the recommended steps (and breaking changes like that one) here.

=========

EDIT:

As Bond - Java Bond suggests, these are the breaking changes in case of the link goes dead:

2.0.0-beta.7 (2016-05-19) BREAKING CHANGES

Angular Update to 2.0.0-rc.1

Angular has been updated to 2.0.0-rc.1, follow these steps to update Angular.

  1. Edit your package.json and remove the angular2 entry:

    "angular2": "2.0.0-beta.15"
    
  2. Then, run the following command from a terminal to update Ionic and Angular, or take a look at the starter's package.json changes and update each version:

    npm install --save [email protected] @angular/core @angular/compiler @angular/common @angular/platform-browser @angular/platform-browser-dynamic @angular/router @angular/http [email protected] [email protected] reflect-metadata
    
  3. Run the following command from a terminal to update the gulp task for ionic-gulp-scripts-copy:

    npm install --save-dev [email protected]
    
  4. Then, change any imports in your application from angular2 to @angular. For example, the following.

    import {ViewChild} from 'angular2/core';
    import {Http} from 'angular2/http';
    

    becomes

    import {ViewChild} from '@angular/core';
    import {Http} from '@angular/http';
    
  5. Remove the import for angular2-polyfills in index.html:

    <script src="build/js/angular2-polyfills.js"></script>
    

    and replace it with the following scripts:

    <script src="build/js/zone.js"></script>
    <script src="build/js/Reflect.js"></script>
    
  6. Replace all template variables in ngFor with let. For example:

    *ngFor="#session of group.sessions"
    

    becomes

    *ngFor="let session of group.sessions"
    
  7. Replace all template variables in virtualScroll. For example:

    *virtualItem="#item"
    

    becomes

    *virtualItem="let item"
    
  8. View the Angular Changelog for more in depth changes.

1 Comment

Although this might answer the question, do consider summarizing the link content for benefit of future readers in case the link goes dead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.