Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
209 additions
and
242 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Routes } from '@angular/router'; | ||
import { HomeComponent } from './components/home.component'; | ||
import { LoginComponent } from './components/login.component'; | ||
|
||
export const routes: Routes = [ | ||
{ path: '', component: LoginComponent }, | ||
{ path: 'home', component: HomeComponent }, | ||
{ path: 'login', component: LoginComponent }, | ||
]; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,48 @@ | ||
/* | ||
* Providers provided by Angular | ||
* Angular Modules | ||
*/ | ||
import {provide, enableProdMode, OnInit} from '@angular/core'; | ||
import {bootstrap} from '@angular/platform-browser-dynamic'; | ||
import {LocationStrategy, HashLocationStrategy} from '@angular/common'; | ||
|
||
// ROUTER | ||
import {ROUTER_PROVIDERS, RouteConfig, ROUTER_DIRECTIVES } from '@angular/router-deprecated'; | ||
|
||
// HTTP | ||
import {HTTP_PROVIDERS} from '@angular/http'; | ||
|
||
// Decorators | ||
import {Component} from '@angular/core'; | ||
import { enableProdMode, NgModule, Component } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { LocationStrategy, HashLocationStrategy } from '@angular/common'; | ||
import { RouterModule, Router } from '@angular/router'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { HttpModule } from '@angular/http'; | ||
|
||
// Setup redux with ngrx | ||
import { Store, StoreModule } from '@ngrx/store'; | ||
import { authStore, authInitialState } from './store/auth.store'; | ||
|
||
/** | ||
* setup redux | ||
* Import our child components | ||
*/ | ||
import {createStore} from 'redux'; | ||
import {rootReducer} from './rootReducer'; | ||
import {Actions} from './actions'; | ||
const appStore = createStore(rootReducer); | ||
import { LoginComponent } from './components/login.component'; | ||
import { HomeComponent } from './components/home.component'; | ||
import { AppComponent } from './components/app.component'; | ||
|
||
import { routes } from './app.routes'; | ||
|
||
/** | ||
* Import our child components | ||
* Import the authentication service to be injected into our component | ||
*/ | ||
import {LoginComponent} from './components/login'; | ||
import {HomeComponent} from './components/home'; | ||
import { Authentication } from './services/authentication'; | ||
|
||
|
||
/* | ||
* App Component | ||
* Top Level Component | ||
* provide('AppStore', { useValue: appStore }), | ||
*/ | ||
@Component({ | ||
// The selector is what angular internally uses | ||
selector: 'ae-app', // <app></app> | ||
directives: [ROUTER_DIRECTIVES, LoginComponent, HomeComponent], | ||
template: ` | ||
<div> | ||
<router-outlet></router-outlet> | ||
</div> | ||
` | ||
@NgModule({ | ||
imports: [ | ||
BrowserModule, | ||
FormsModule, | ||
HttpModule, | ||
ReactiveFormsModule, | ||
RouterModule.forRoot(routes, { useHash: true }), | ||
StoreModule.provideStore({ authStore }, { authStore: authInitialState }), | ||
], | ||
providers: [Authentication], | ||
declarations: [AppComponent, HomeComponent, LoginComponent], | ||
bootstrap: [AppComponent] | ||
}) | ||
@RouteConfig([ | ||
{ path: '/', component: LoginComponent, name: 'Login' }, | ||
{ path: '/login', component: LoginComponent, name: 'Login' }, | ||
{ path: '/home', component: HomeComponent, name: 'Home' } | ||
]) | ||
export class AppComponent implements OnInit { | ||
//component initialization | ||
ngOnInit() { | ||
//check authentication | ||
} | ||
|
||
checkAuthentication() { | ||
|
||
} | ||
} | ||
|
||
/* | ||
* Bootstrap our Angular app with a top level component `App` and inject | ||
* our Services and Providers into Angular's dependency injection | ||
*/ | ||
bootstrap(AppComponent, [ | ||
...HTTP_PROVIDERS, | ||
...ROUTER_PROVIDERS, | ||
provide(LocationStrategy, { useClass: HashLocationStrategy }), | ||
provide('AppStore', { useValue: appStore }), | ||
Actions | ||
]).catch(err => console.error(err)); | ||
export class AppModule { } | ||
platformBrowserDynamic().bootstrapModule(AppModule); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Import decorators and services from angular | ||
*/ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
/* | ||
* App Component | ||
* Top Level Component | ||
*/ | ||
@Component({ | ||
// The selector is what angular internally uses | ||
selector: 'ae-app', // <app></app> | ||
template: ` | ||
<div> | ||
<router-outlet></router-outlet> | ||
</div> | ||
` | ||
}) | ||
export class AppComponent implements OnInit { | ||
//component initialization | ||
ngOnInit() { | ||
//check authentication | ||
} | ||
|
||
checkAuthentication() {} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Import decorators and services from angular | ||
*/ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { FormControl, FormGroup } from '@angular/forms'; | ||
|
||
/** | ||
* Import the ngrx configured store | ||
*/ | ||
import { Store } from '@ngrx/store'; | ||
import { AppState } from './../store/appState.store'; | ||
|
||
@Component({ | ||
selector: 'ae-home', | ||
template: ` | ||
<div [formGroup]="messageForm"> | ||
<h1>{{messageForm.controls['messageText'].value}}</h1> | ||
<input type="text" formControlName="messageText"/> | ||
</div> | ||
` | ||
}) | ||
export class HomeComponent implements OnInit { | ||
name: string; | ||
|
||
messageForm = new FormGroup({ | ||
messageText: new FormControl('Angular2'), | ||
}); | ||
|
||
constructor(public store: Store<AppState>) { | ||
let state = this.store.select('authStore').subscribe((state: any) => { | ||
this.name = state.username; | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
// Our API | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.