I'm learning Angular and have a simple project (single page web), linked up and successfully hosted through Firebase.
The problem is, although I can view the page fine when I serve it locally (ng serve in the directory), when I serve it or deploy it to Firebase, it then only renders the HTML (and not the content linked to the angular component).
Photo of directory file structure: Hosting under src file, firebase.json file at the same level as angular-cli.json
index.html:
</head>
<body>
<h1>NORMAL HTML!</h1>
<app-root></app-root>
<h1>THERE SHOULD BE SOME STUFF ABOVE ME!</h1>
app.component.ts is a standard component:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app works!';
}
app.component.html:
<h1>
{{title}}
</h1>
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
AppRoutingModule,
RouterModule,
],
providers: [AppRoutingModule],
bootstrap: [AppComponent]
})
export class AppModule { }
app-routing.module.ts:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
const routes: Routes = [
{
path: '',
component: AppComponent,
pathMatch: 'full'
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
providers: []
})
export class AppRoutingModule { }
main.ts:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/app.module';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
firebase.json:
{
"hosting": {
"public": "src"
}
}
.firebaserc:
{
"projects": {
"default": "alicespyglass-tinker"
}
}
I'm stumped.