Reputation: 547
Please forgive me if the question is very simple. I have just started learning 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:
<!--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
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
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
<!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 ?
Upvotes: 3
Views: 9282
Reputation: 599
You don't have backticks or quotes in your template:
The template is a multi-line string within ECMAScript 2015 backticks (
). 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.
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';
}
Upvotes: 3