【发布时间】:2017-06-12 11:07:43
【问题描述】:
我用 ng-cli 创建了一个全新的应用程序 用这个非常简单的代码^^
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor(private my: string) {}
}
我已经进入控制台
例外:没有字符串的提供者!
我没有在代码中看到任何错误,所以 怎么了!
在 ng-book 我可以阅读
export class Article {
title: string;
link: string;
votes: number;
constructor(title: string, link: string, votes?: number) {
this.title = title;
this.link = link;
this.votes = votes || 0;
}
}
看看
https://github.com/Microsoft/TypeScriptSamples/blob/master/greeter/greeter.ts
【问题讨论】:
-
DI 系统正在尝试为您注入一个值;你期望
my是什么?价值应该从哪里来? -
纯 ts 中的 ts 类型的字符串是有效的 sintax
-
我不知道你想说什么。
-
我写了一个服务
标签: angular typescript ionic3