错误:Can';t解析TypeDecorator的所有参数:Angular 2 RC-6
我犯这个错误已经一天多了,我不知道为什么 应用程序模块错误:Can';t解析TypeDecorator的所有参数:Angular 2 RC-6,angular,Angular,我犯这个错误已经一天多了,我不知道为什么 应用程序模块 import {NgModule} from "@angular/core"; import {BrowserModule} from "@angular/platform-browser"; import {AppComponent} from "./app.component"; import {FormsModule} from "@angular/forms"; import {LoginComponent} from "./Log
import {NgModule} from "@angular/core";
import {BrowserModule} from "@angular/platform-browser";
import {AppComponent} from "./app.component";
import {FormsModule} from "@angular/forms";
import {LoginComponent} from "./Login/login";
import {LoginService} from "./Login/login.service";
@NgModule({
imports: [BrowserModule, FormsModule],
declarations: [AppComponent,
LoginComponent],
providers:[LoginService],
bootstrap: [AppComponent]
})
export class AppModule {
}
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: '<login></login>'
})
export class AppComponent {
}
login.ts
import {Component} from '@angular/core';
import {LoginModel} from "./login.model";
import {LoginService} from "./login.service";
@Component({
moduleId: module.id,
selector: 'login',
templateUrl:'./login.html',
styleUrls:['../css/styles.css'],
})
export class LoginComponent{
login:LoginModel = new LoginModel();
constructor(public loginService:LoginService){
}
onSubmit() {
this.loginService.output();
}
登录服务
import {Injectable, Inject} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Rx';
@Injectable
export class LoginService {
output(){
console.log("You are in the service output class...");
}
}
目前,我正在尝试编译应用程序,以便创建路由和服务。这是整个项目的重点,但我一直碰壁。如有任何建议,将不胜感激
GitHub链接
在我的例子中,login.service.ts在
可注入()中缺少()
您是否尝试删除login:LoginModel=new LoginModel()
现在吗?可能是因为您忘记了()
在@Injectable
的末尾,我在angular.io上的某个地方看到这可能会导致一个奇怪的bug,他们不知道为什么。OMG。。。。。。。。。。浪费了一点时间!!!!!!!!!!!非常感谢你。
import {Injectable, Inject} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Rx';
@Injectable
export class LoginService {
output(){
console.log("You are in the service output class...");
}
}