ng服务显示我的角度项目的错误

时间:2017-10-01 11:17:36

标签: angular

这是我的app.component.html文件:

   <div class="navbar navbar-default ">
      <div class="container">
        <div class="navbar-header">
          <a href="../" class="navbar-brand">Navigation-Angular</a>
          <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
        </div>
        <div class="navbar-collapse collapse" id="navbar-main">
          <ul class="nav navbar-nav">

            <li>
              <a routerLink="help">Help</a>
            </li>
             <li>
              <a routerLink="about">About</a>
            </li> <li>
              <a routerLink="services">Services</a>
            </li>
          </ul>
        </div>
      </div>
    </div>

<div class="container">
  <router-outlet></router-outlet>
  </div>

这是services.component.ts文件

import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
@Component({
  selector: 'app-services',
  templateUrl: './services.component.html',
  styleUrls: ['./services.component.css']
})
export class ServicesComponent  {

  constructor(private http:Http) { }

  ngOnInit() {
  }

  uploadFile(event)
  {
    let elem=event.target;
    if(elem.files.length>0)
  {
    console.log(elem.files[0]);
    let formData = new FormData();
    formData.append('file',elem.files[0]);
    this.http.post('http://localhost/php_for_angular/returnIt.php',formData).subscribe((data)=>{

      console.log('return data ',data);

    },(error)=>{
       console.log('error! ',error);
    });

  }
  }
}

这是app.router.ts文件

import {ModuleWithProviders} from '@angular/core';
import {Routes,RouterModule} from '@angular/router';

import {AppComponent} from './app.component';
import {AboutComponent} from './about/about.component';
import {ServicesComponent} from './services/services.component';
import {HelpComponent} from './help/help.component';
export const router: Routes=[

{path:'',redirectTo:'about',pathMatch:'full'},
{path:'help',component:HelpComponent},
{path:'about',component:AboutComponent},
{path:'services',component:ServicesComponent}
];

export const routes:ModuleWithProviders=RouterModule.forRoot(router);

这是我在ng serve命令期间得到的错误:

ERROR in C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts (22,14): ',' expected.   
ERROR in C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts (22,25): ',' expected.   
ERROR in C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts (22,31): ';' expected.   
ERROR in C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts (22,37): ';' expected.  
ERROR in C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts (22,5): Cannot find name 'post'.  
ERROR in C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts (22,10): Cannot find name 'arg0'.  
ERROR in C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts (22,16): Cannot find name 'any'.  
ERROR in C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts (22,21): Cannot find name 'arg1'.  
ERROR in C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts (22,27): Cannot find name 'any'.  
ERROR in C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts (22,33): Cannot find name 'any'.   
ERROR in C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts (24,16): Cannot find name 'any'.
webpack: Failed to compile.

**更新typscript和npm后,仍然会导致错误!**

错误在C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts(22,16):'any'只是指一种类型,但我 s在这里用作值。

C中的错误:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts(22,21):找不到名称'arg1'。

错误在C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts(22,27):'any'只是指一种类型,但是我 s在这里用作值。

错误在C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts(22,33):'any'只是指一种类型,但我 s在这里用作值。

错误在C:/angular_project/route-project/node_modules/@angular/http/src/http_module.d.ts(24,16):'any'只是指一种类型,但我 s在这里用作值。

0 个答案:

没有答案