这个错误已经发生一天多了,但我不知道为什么。
应用程序模块
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 {
}
登录.model.ts
export class LoginModel{
private userName: string;
private password: string;
constructor(userName: string='', password: string=''){
this.userName = userName;
this.password = password;
}
}
登录.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 缺少 Injectable()
中的 ()
关于angular - 错误: Can't resolve all parameters for TypeDecorator: Angular 2 RC-6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39596581/