title: How do I prevent Angular from loading a Component twice?
body: <p>My Angular app is loading a component twice. Initially, I had <code>&lt;router-outlet&gt;&lt;/router-outlet&gt;</code> in my component's template and it was working fine but was still giving me these errors: </p>
  
  <pre><code>core.umd.js:3257 EXCEPTION: Uncaught (in promise): Error: Cannot find primary outlet to load 'AppComponent'
  core.umd.js:3262 ORIGINAL STACKTRACE:
  core.umd.js:3263 Error: Uncaught (in promise): Error: Cannot find primary outlet to load 'AppComponent'
  zone.js:355 Unhandled Promise rejection: Cannot find primary outlet to load 'AppComponent' ; Zone: angular ; Task: Promise.then ; Value: Error: Cannot find primary outlet to load 'AppComponent'(…) Error: Cannot find primary outlet to load 'AppComponent' 
  zone.js:357 Error: Uncaught (in promise): Error: Cannot find primary outlet to load 'AppComponent'
  </code></pre>
  
  <p>To resolve these errors, I added <code>&lt;router-outlet&gt;&lt;/router-outlet&gt;</code> to my template. But now my app is loading my component twice. </p>
  
  <p><strong>app.component.ts</strong></p>
  
  <pre><code>import { Component } from '@angular/core';
  
  @Component({
  moduleId: module.id
    selector:'body', 
    templateUrl: 'app.component.html', 
    styleUrls: ['app.component.css']
  })
  
  export class AppComponent {
    title = 'Doctor Application';
  }
  </code></pre>
  
  <p><strong>app-routing.module.ts</strong></p>
  
  <pre><code>import { NgModule }             from '@angular/core';
  import { RouterModule, Routes } from '@angular/router';
  
  import { AppComponent }   from './app.component';
  
  const routes: Routes = [
    { path: '', component: AppComponent  },
  ];
  
  @NgModule({
    imports: [ RouterModule.forRoot(routes) ],
    exports: [ RouterModule ]
  })
  
  export class AppRoutingModule {}
  </code></pre>
  
  <p><strong>app.component.html</strong></p>
  
  <pre><code>&lt;h1&gt;{{title}}&lt;/h1&gt;
  &lt;router-outlet&gt;&lt;/router-outlet&gt;
  </code></pre>