0

I connected to firebase, but I can't get it to render my Angular tags. I've followed the below article and several others, and I'm just not getting it to render.

Angular 4 Firebase - HTML not rendering / reading angular tag

When I deploy to firebase, it renders "test 3" from the native HTML, but not the app-root or component1. It's driving me crazy! Can someone help?

Index from dist folder:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Welcome to Firebase Hosting </title>

    <!-- update the version number as needed -->
    <script defer src="/__/firebase/8.0.1/firebase-app.js"></script>
    <!-- include only the Firebase features as you need -->
    <script defer src="/__/firebase/8.0.1/firebase-auth.js"></script>
    <script defer src="/__/firebase/8.0.1/firebase-database.js"></script>
    <script defer src="/__/firebase/8.0.1/firebase-firestore.js"></script>
    <script defer src="/__/firebase/8.0.1/firebase-functions.js"></script>
    <script defer src="/__/firebase/8.0.1/firebase-messaging.js"></script>
    <script defer src="/__/firebase/8.0.1/firebase-storage.js"></script>
    <script defer src="/__/firebase/8.0.1/firebase-analytics.js"></script>
    <script defer src="/__/firebase/8.0.1/firebase-remote-config.js"></script>
    <script defer src="/__/firebase/8.0.1/firebase-performance.js"></script>
    <!-- 
      initialize the SDK after all desired features are loaded, set useEmulator to false
      to avoid connecting the SDK to running emulators.
    -->
    <script defer src="/__/firebase/init.js?useEmulator=true"></script>

  </head>
  <body>
    test 3
    <app-root></app-root>
    <app-component1></app-component1>
  </body>

environment (and environment.prod):

export const environment = {
  production: false,
  firebase: {
    apiKey: "...",
    authDomain: "test1-9b8fb.firebaseapp.com",
    databaseURL: "...",
    projectId: "test1-9b8fb",
    storageBucket: "test1-9b8fb.appspot.com",
    messagingSenderId: "...",
    appId: "...",
    measurementId: "..."
  }
};

.firebasesrc:

{
  "projects": {
    "default": "test1-9b8fb"
  },
  "targets": {
    "test1-9b8fb": {
      "hosting": {
        "firebase-test": [
          "test1-9b8fb"
        ]
      }
    }
  }
}

firebase.json:

{
  "hosting": {
    "public": "dist",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

angular.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "firebase-test": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/firebase-test",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "assets": [
              "src/app",
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb",
                  "maximumError": "10kb"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "firebase-test:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "firebase-test:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "firebase-test:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "firebase-test:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "firebase-test:serve:production"
            }
          }
        },
        "deploy": {
          "builder": "@angular/fire:deploy",
          "options": {}
        }
      }
    }
  },
  "defaultProject": "firebase-test"
}

app.module:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { Component1Component } from './component1/component1.component';
import { environment } from 'src/environments/environment';
import { AngularFireModule } from '@angular/fire';

@NgModule({
  declarations: [
    AppComponent,
    Component1Component,
   
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    AngularFireModule.initializeApp(environment.firebase)
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.html:

<app-component1></app-component1>
App works!
<router-outlet></router-outlet>

component1.component.html:

<p>component1 works!</p>

Angular 4 Firebase - HTML not rendering / reading angular tag

1 Answer 1

1

I found it. Everywhere that talks about this subject says to use "dist" for your public file, but that's not quite right. I set it to "dist/firebase-test" and it worked just fine.

Turns out the index.html in "dist" doesn't automatically go one level down to get to the app component stuff.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.