Angular 无法识别TypeScript多行代码
请帮助我在Sublime和VS代码中使用Typescript编码时解决此错误。只有当所有模板:代码都在一行中时,才能识别并在浏览器中正确显示Angular 无法识别TypeScript多行代码,angular,typescript,sublimetext3,visual-studio-code,Angular,Typescript,Sublimetext3,Visual Studio Code,请帮助我在Sublime和VS代码中使用Typescript编码时解决此错误。只有当所有模板:代码都在一行中时,才能识别并在浏览器中正确显示 template:'<h1>{{title}}</h1><h2>{{hero.name}} details!</h2><div><label>id: </label>{{hero.id}}</div><div><label>name: &
template:'<h1>{{title}}</h1><h2>{{hero.name}} details!</h2><div><label>id: </label>{{hero.id}}</div><div><label>name: </label>{{hero.name}}</div>',
当我尝试将其分解为多行时,浏览器无法按预期显示结果
下面是我正在做的全部代码:
import { Component } from '@angular/core';
export class Hero {
id: number;
name: string;
}
@Component({
selector: 'my-app',
template:'<h1>{{title}}</h1><h2>{{hero.name}} details!</h2><div><label>id: </label>{{hero.id}}</div><div><label>name: </label>{{hero.name}}</div>',
})
export class AppComponent {
title = 'Tour of Heroes';
hero = Hero {
id: 1;
name: 'Windstorm';
}
}
本教程来自angular.io编写多行代码时需要使用反勾号
@Component({
template: `
//code here
`
})
使用包含大量HTML的模板
@Component({
templateUrl: "PATH HERE"
})
希望这有帮助写多行代码时需要使用反勾号
@Component({
template: `
//code here
`
})
使用包含大量HTML的模板
@Component({
templateUrl: "PATH HERE"
})
希望这能帮我的忙!错过了教程中的内容。我的错!错过了教程中的内容。