[英]Module parse failed:You may need an appropriate loader to handle this file type
Please forgive me if the question is very simple. 如果问题很简单,请原谅我。 I have just started learning Angular.
我刚刚开始学习Angular。 I am trying my first app.
我正在尝试我的第一个应用程序。 But it does not compile.
但是它不能编译。 Because it does not recognize part of my code.
因为它无法识别我的代码的一部分。 I was wondering if somebody can give me some hints on what I am doing wrong in here?
我想知道是否有人可以给我一些暗示我在这里做错了什么?
app.component.html file: app.component.html文件:
<!--The whole content below can be removed with the new code.-->
<div style="text-align:center">
<h1>
Welcome to {{pageTitle}}!!
</h1>
... Starter Files ...
</div>
app.component.ts file app.component.ts文件
import { Component } from '@angular/core';
@Component({
selector: 'pm-root',
template: <div><h1>{{pageTitle}}</h1></div> // **this line of code created error**
})
export class AppComponent {
pageTitle: string = 'Angular: Getting Started';
}
app.module.ts app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
index.html 的index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Acme Product Management</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<pm-root></pm-root>
</body>
</html>
here is the error : 这是错误:
would you please give some help on how to fix this ?
您能提供一些解决方法的帮助吗?
You don't have backticks or quotes in your template: 您的模板中没有反引号或引号:
The template is a multi-line string within ECMAScript 2015 backticks (
). The backtick (
模板是ECMAScript 2015反引号(
). The backtick (
的多行字符串). The backtick (
). The backtick (
)—which is not the same character as a single quote (')—allows you to compose a string over several lines, which makes the HTML more readable.). The backtick (
)与单引号(')不同,它使您可以在多行上组成一个字符串,从而使HTML更具可读性。
import { Component } from '@angular/core';
@Component({
selector: 'pm-root',
template: `<div><h1>{{pageTitle}}</h1></div>` // **added backticks**
})
export class AppComponent {
pageTitle: string = 'Angular: Getting Started';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.