Angular 2: My component does not work in index

1

I'd like to interpret my component within my index.html, about.html, contact.html, among other pages.

I created the component using the Angular cli.

My structure is as follows:

The code inside my app.module.ts file is:

import { AppComponent } from './app.component';
import { NavbarModule } from './navbar/navbar.module';



@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    NavbarModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

In my app.components , I did not even move.

In my navbar.module.ts file it looks like this:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';


import { NavbarComponent } from './navbar.component';

@NgModule({
  imports: [
    CommonModule
  ],
  declarations: [
    NavbarComponent
  ],
  exports: [
    NavbarComponent
  ]
})
export class NavbarModule { }

My navbar-components file looks like this:

import {Component, OnInit} from '@ angular / core';

@Component({
  selector: 'app-navbar',
  templateUrl: './navbar.component.html',
  styleUrls: ['./navbar.component.css']
})
export class NavbarComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}

Within my file navbar.component.html has mine that I would like to import into the index. And in index.html, I'm trying to call my componenet, but it will not.

I need some solution, please.

    
asked by anonymous 21.11.2017 / 16:41

2 answers

1

Insert the tag   inside the app.component.html that will work.

    
22.11.2017 / 11:47
0

Use this selector to put it inside In your case, on the line where you want to put nav use

<app-navbar></app-navbar>
    
22.11.2017 / 11:25