Angular2错误:创建搜索栏所需的导入

时间:2016-05-10 20:43:45

标签: javascript html angular

我尝试使用搜索栏创建一个基本上是ebay克隆的网站,但在尝试导入正确的文件时出错。

这是错误的截图: enter image description here

以下是plunker(完整项目)的链接:

 plnkr.co/edit/1lcI4dURHwA8D9IQtqSf?p=info

以下是完整项目的Dropbox版本的链接(请注意,这不包括nodes_modules文件夹):

https://www.dropbox.com/s/quuh3s27pvv5jl6/ImportProjectErrors.zip?dl=0

我试图更改的文件的代码(youtubesearchapp.ts):

import {boostrap,
    View,
 ON_PUSH} 
 from 'angular2/core';
import {
  bind,
  Component,
  Injectable,
} from 'angular2/core';
import{
  CORE_DIRECTIVES,
} from 'angular2/common'


import { ChangeDetectionStrategy} from 'angular2/core';
import {
  Http, HTTP_BINDINGS
} from 'angular2/http'
import {
  FormBuilder, 
  Validators,
  FORM_BINDINGS,
  FORM_DIRECTIVES
} from 'angular2/common';

其他文件导入错误的屏幕截图:

dropbox.com/s/i12eg8za9kmeii7/Screen%20Shot%202016-05-10%20at%203.37.59%20PM.png?dl=0

我尝试更改的其他文件的代码(wikipedia.service.ts)

import { Injectable } from 'angular2/common';



import { Jsonp, URLSearchParams } from 'angular2/http';

1 个答案:

答案 0 :(得分:1)

您使用的是哪个版本的角度2?如果您使用的是RC 0或RC 1.进口已经改变:

To import various symbols please adjust the paths in the following way:

angular2/core -> @angular/core
angular2/compiler -> @angular/compiler
angular2/common -> @angular/common
angular2/platform/browser -> @angular/platform-browser (applications with precompiled templates) + @angular/platform-browser-dynamic (applications that compile templates on the fly)
angular2/platform/server -> @angular/platform-server
angular2/testing -> @angular/core/testing (it/describe/..) + @angular/compiler/testing (TestComponentBuilder) + @angular/platform-browser/testing
angular2/upgrade -> @angular/upgrade
angular2/http -> @angular/http
angular2/router -> @angular/router-deprecated (snapshot of the component router from beta.17 for backwards compatibility)
new package: @angular/router - component router with several breaking changes

来源:https://github.com/angular/angular/blob/master/CHANGELOG.md