Last active
October 8, 2016 15:35
-
-
Save sebble/4ee72219a1b67677c7eef9e9f7422326 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { NginxlogService } from './nginxlog.service'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
title = 'app works!'; | |
constructor(private nginxlogService: NginxlogService) { } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { FormsModule } from '@angular/forms'; | |
import { HttpModule } from '@angular/http'; | |
import { RouterModule } from '@angular/router'; | |
import { AppComponent } from './app.component'; | |
import { AppRoutingModule } from './routing.module'; | |
import { OneComponent } from './one/one.component'; | |
import { TwoComponent } from './two/two.component'; | |
import { NginxlogService } from './nginxlog.service'; | |
@NgModule({ | |
declarations: [ | |
AppComponent, | |
OneComponent, | |
TwoComponent, | |
], | |
imports: [ | |
BrowserModule, | |
FormsModule, | |
HttpModule, | |
AppRoutingModule, | |
], | |
providers: [NginxlogService], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { Router, NavigationEnd } from '@angular/router'; | |
@Injectable() | |
export class NginxlogService { | |
constructor(private router: Router) { | |
router.events.subscribe(e => { | |
if (e instanceof NavigationEnd) { | |
//console.log(e['urlAfterRedirects']); | |
let request = new XMLHttpRequest(); | |
request.open('OPTIONS', e['urlAfterRedirects'], true); | |
request.send(); | |
} | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule } from '@angular/core'; | |
import { RouterModule } from '@angular/router'; | |
import { OneComponent } from './one/one.component'; | |
import { TwoComponent } from './two/two.component'; | |
@NgModule({ | |
imports: [ | |
RouterModule.forRoot([ | |
{ path: '', redirectTo: '/one', pathMatch: 'full' }, | |
{ path: 'one', component: OneComponent }, | |
{ path: 'two', component: TwoComponent } | |
]) | |
], | |
exports: [ | |
RouterModule | |
] | |
}) | |
export class AppRoutingModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment