I have just started learning angular and i tried to create a simple dashboard.
I've created 2 componentents, DashboardComponent and SidebarComponent.
Dashboard loads fine, but when i load SidebarComponent i'm getting a error on browser "The template specified for component SidebarComponent is not a string"
SidebarComponent:
import { Component } from '@angular/core';
@Component({
selector: 'sidebar-component',
templateUrl: './sidebar.component.ts',
styleUrls: ['./sidebar.component.scss']
})
export class SidebarComponent {}
App.module
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { SidebarComponent } from './sidebar/sidebar.component';
@NgModule({
declarations: [
AppComponent,
DashboardComponent,
SidebarComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Both of them are also loaded in app.component
<sidebar-component></sidebar-component>
<dashboard></dashboard>
The error speaks for itself...
You're referring to a .ts
file instead of .html
.
Change this line:
templateUrl: './sidebar.component.ts'
to:
templateUrl: './sidebar.component.html'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With