I need my Angular app to be completely self contained so it's browsable when opened from file explorer rather than served from a website. I've made a simple example which uses Material:
ng add @angular/material
ng add ngx-build-plus
app.component.html
<div style="text-align:center">
<h1>
Welcome to {{ title }}!
</h1>
<div>
<mat-slider min="1" max="100" step="1" value="50"></mat-slider>
</div>
</div>
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatSliderModule } from '@angular/material/slider';
import { SliderComponent } from './slider/slider.component';
@NgModule({
declarations: [
AppComponent,
SliderComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MatSliderModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AngularTourOfHeroes</title>
<base href="#"> <!-- Updated from "/" -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<app-root></app-root>
</body>
</html>
When served with ng serve, the page correctly renders like so:
If I build the project using ng build --prod --single-bundle and open the resulting html file in the browser, I see no errors in the Network or Console, but the slider doesn't render: