错误:无法解析TypeDecorator的所有参数:Angular 2 RC-6 [英] Error: Can't resolve all parameters for TypeDecorator: Angular 2 RC-6

查看:49
本文介绍了错误:无法解析TypeDecorator的所有参数:Angular 2 RC-6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一天以上的错误了,我不确定为什么.

app.module

 从"@ angular/core"导入{NgModule};从"@ angular/platform-b​​rowser"导入{BrowserModule};从"./app.component"导入{AppComponent};从"@ angular/forms"导入{FormsModule};从"./Login/login"导入{LoginComponent};从"./Login/login.service"导入{LoginService};@NgModule({导入:[BrowserModule,FormsModule],声明:[AppComponent,LoginComponent],提供者:[LoginService],引导程序:[AppComponent]})导出类AppModule {} 

app.component.ts

 从'@ angular/core'导入{组件};@零件({选择器:"my-app",模板:< login></login>"})导出类AppComponent {} 

login.model.ts

 导出类LoginModel {私人用户名:字符串;私人密码:字符串;构造函数(用户名:字符串='',密码:字符串=''){this.userName =用户名;this.password =密码;}} 

login.ts

 从'@ angular/core'导入{Component};从"./login.model"导入{LoginModel};从"./login.service"导入{LoginService};@零件({moduleId:module.id,选择器:登录",templateUrl:'./login.html',styleUrls:['../css/styles.css'],})导出类LoginComponent {login:LoginModel = new LoginModel();构造函数(公共loginService:LoginService){}onSubmit(){this.loginService.output();} 

login.service

 从'@ angular/core'导入{Injectable,Inject};从'@ angular/http'导入{Http,Response};从'rxjs/Rx'导入{Observable};@可注射导出类LoginService {输出(){console.log(您在服务输出类中...");}} 

当前,我只是在尝试编译应用程序,以便创建路由和服务.那是项目的重点,但我一直在碰壁.任何建议将不胜感激.

GitHub链接

LINK

解决方案

在我的情况下,login.service.ts在 Injectable()中缺少了() >

I have had this error for over a day and I am not sure why.

app.module

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.model.ts

export class LoginModel{

    private userName: string;
    private password: string;

    constructor(userName: string='', password: string=''){
        this.userName = userName;
        this.password = password;
    }

}

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();
    }

login.service

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...");
    }
}

Currently I am just trying to get the application to compile so I can creating the routes and services. That was the whole point of the project but I keep hitting walls. Any advice will be greatly appreciated.

GitHub Link

LINK

解决方案

In my case login.service.ts was missing the () in Injectable()

这篇关于错误:无法解析TypeDecorator的所有参数:Angular 2 RC-6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆