【发布时间】:2017-09-22 14:32:54
【问题描述】:
尝试 Angular 演示并遇到关于 [ts] 找不到 div 的错误。
import { Component } from "@angular/core";
import { FormControl } from "@angular/forms";
@Component({
selector: "main",
template: '
<div>
<label for="first-name-input">First Name:</label>
<input type="text" [formControl]="firstNameInput"
</div>',
})
export class AppComponent {
public firstNameInput: FormControl = new FormControl("");
public lastNameInput: FormControl = new FormControl("");
public message: string = "Hello World!";
}
使用 Core2.0 和新的 Angular 下载。以上是什么意思?
这是 tslint.json
{
"extends": "tslint:latest",
"rules": {
"arrow-parens": true,
"interface-name": [ true, "never-prefix" ],
"curly": true,
"no-var-requires": false,
"no-string-literal": false,
"no-console": [ false ],
"object-literal-sort-keys": false,
"ordered-imports": [ false ]
},
"jsRules": {
"curly": true
},
"rulesDirectory": []
}
第一次使用 typescript 和 angular。
【问题讨论】:
-
你应该使用反引号:`。不是单引号:'。请参阅 template literals 上的文档
标签: angular typescript asp.net-core-2.0