As a newcomer to Angular 2, I have embarked on a small project with the following files:
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { MaterialModule } from './material/material.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
MaterialModule,
BrowserAnimationsModule,
AppComponent,
NgModule
],
bootstrap: [AppComponent]
})
export class AppModule {
}
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'App Title';
}
app.component.html
<span>Welcome to {{title}}</span>
I have also included my index.html below:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8>
<title>My App</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>
<app-root></app-root>
</body>
</html>
Although everything is compiling without any errors, the <app-root>
tag remains empty on the final page and fails to display my template HTML. I have tested changing the template URL to see if it's a loading issue, but even then, it cannot locate the template file causing the compilation to fail. This leads me to believe that the problem lies elsewhere.
Am I overlooking something important here?