title: Angular routing from app.component.ts
body: <p>Hello I have angularjs app and routing module (AppRoutingModule) all works good when I am inserting <code>&lt;router-outlet&gt;&lt;/router-outlet&gt;</code> in app.component.html,
  but what if I want show some page registered users and not show others.</p>
  
  <p>I mean this in my app.component.ts</p>
  
  <p>if (something) {
     show example page by default
  } else {
    show example2 page
  }</p>
  
  <p>app-routing.module.ts</p>
  
  <pre><code>import { NgModule } from '@angular/core';
  // Routing
  import { RouterModule, Routes } from '@angular/router';
  import { HomeComponent } from './home/home.component';
  import { LoginComponent } from './login/login.component';
  import { RegistrationComponent } from './registration/registration.component';
  
  const appRoutes: Routes = [
    { path: '', component: HomeComponent },
    { path: 'login', component: LoginComponent },
    { path: 'registration', component: RegistrationComponent}
  ];
  
  @NgModule({
    imports: [
      RouterModule.forRoot(
        appRoutes,
  
      )
    ],
    exports: [
      RouterModule
    ]
  })
  export class AppRoutingModule {}
  </code></pre>
  
  <p>app.module.ts</p>
  
  <pre><code>import { BrowserModule } from '@angular/platform-browser';
  import { NgModule } from '@angular/core';
  
  import { AppComponent } from './app.component';
  import { AlertModule } from 'ngx-bootstrap';
  
  // Import the AF2 Module
  import { AngularFireModule } from 'angularfire2';
  import { AngularFireAuthModule } from 'angularfire2/auth';
  import { AngularFireDatabaseModule } from 'angularfire2/database';
  import { environment } from '../environments/environment';
  
  import { AppRoutingModule } from './app-routing.module';
  import { HomeComponent } from './home/home.component';
  import { LoginComponent } from './login/login.component';
  import { RegistrationComponent } from './registration/registration.component';
  
  @NgModule({
    declarations: [
      AppComponent,
      RegistrationComponent,
      HomeComponent,
      LoginComponent
    ],
    imports: [
      BrowserModule,
      AlertModule.forRoot(),
      AngularFireModule.initializeApp(environment.firebase),
      AngularFireAuthModule,
      AngularFireDatabaseModule,
      AppRoutingModule
    ],
    providers: [],
    bootstrap: [AppComponent]
  })
  export class AppModule { }
  </code></pre>
  
  <p>app.component.ts</p>
  
  <pre><code>import { Component } from '@angular/core';
  import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
  @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
  })
  export class AppComponent {
    title = 'app';
    items: FirebaseListObservable&lt;any[]&gt;;
    constructor(db: AngularFireDatabase) {
      this.items = db.list('/sms');
    }
  }
  </code></pre>
  
  <p>app.component.html</p>
  
  <pre><code>&lt;router-outlet&gt;&lt;/router-outlet&gt;
  </code></pre>