forked from kozlice/angular2-webpack-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Upgrade to Angular 2.1.2, also update some deps - Change the way how templates and styles are imported - Freeze deps versions - Ensure code coverage works properly - Example component with HTTP interaction & related tests for it
- Loading branch information
Showing
30 changed files
with
543 additions
and
155 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 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 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,2 @@ | ||
$heading-color: #333; | ||
$heading-highlight-color: #fa2800; |
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,19 +1,14 @@ | ||
import { Component, ViewEncapsulation } from '@angular/core'; | ||
import { AppService } from './app.service'; | ||
|
||
/** | ||
* Styles required here are common for all components (SASS/SCSS versions of normalize.css and flexboxgrid), | ||
* so encapsulation is not used. Other components have their styles scoped with `ViewEncapsulation.Emulated`. | ||
*/ | ||
@Component({ | ||
selector: 'da-app', | ||
template: require('./app.html'), | ||
styles: [ | ||
require('./app.scss') | ||
], | ||
encapsulation: ViewEncapsulation.Native, | ||
providers: [ | ||
AppService | ||
] | ||
templateUrl: './app.html', | ||
styleUrls: ['./app.scss'], | ||
encapsulation: ViewEncapsulation.None, | ||
providers: [] | ||
}) | ||
export class AppComponent { | ||
constructor(public appService: AppService) { | ||
|
||
} | ||
} | ||
export class AppComponent {} |
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 +1,17 @@ | ||
<h1 class="app__title">{{ appService.getTitle() }}</h1> | ||
<div class="container container-fluid"> | ||
<div class="row around-xs center-xs"> | ||
<div class="col-xs"> | ||
<h1 class="app__title">Example Angular 2 application</h1> | ||
</div> | ||
</div> | ||
|
||
<nav class="row around-xs center-xs"> | ||
<div class="col-xs"> | ||
<a [routerLink]="['/']" routerLinkActive="active">Articles</a> | ||
</div> | ||
</nav> | ||
|
||
<hr /> | ||
|
||
<router-outlet></router-outlet> | ||
</div> |
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,14 +1,28 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
|
||
import { HttpModule, JsonpModule } from '@angular/http'; | ||
import { FormsModule } from '@angular/forms'; | ||
|
||
import { routing, appRoutingProviders } from './app.routing'; | ||
import { AppComponent } from 'app/app.component'; | ||
import { ArticleComponent } from './article/article.component'; | ||
import { ArticleListComponent } from './article/article-list.component'; | ||
|
||
/** | ||
* TODO: Example service (HTTP interaction), routing, nested directives, pipe + related tests | ||
*/ | ||
@NgModule({ | ||
imports: [ BrowserModule ], | ||
declarations: [ AppComponent ], | ||
bootstrap: [ AppComponent ] | ||
imports: [ | ||
BrowserModule, | ||
FormsModule, | ||
HttpModule, | ||
JsonpModule, | ||
routing | ||
], | ||
declarations: [ | ||
AppComponent, | ||
ArticleListComponent, | ||
ArticleComponent | ||
], | ||
providers: [appRoutingProviders], | ||
bootstrap: [AppComponent] | ||
}) | ||
export class AppModule { } | ||
export class 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,14 @@ | ||
import { ModuleWithProviders } from '@angular/core'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
|
||
import { ArticleComponent } from './article/article.component'; | ||
import { ArticleListComponent } from './article/article-list.component'; | ||
|
||
const appRoutes: Routes = [ | ||
{ path: 'articles/:id', component: ArticleComponent }, | ||
{ path: '', component: ArticleListComponent }, | ||
]; | ||
|
||
export const appRoutingProviders: any[] = []; | ||
|
||
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); |
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,16 +1,2 @@ | ||
$heading-color: #333; | ||
$heading-highlight-color: #fa2800; | ||
|
||
// App title | ||
// | ||
// :hover - Highlights when hovering | ||
// | ||
// Styleguide base | ||
.app__title { | ||
font-size: 4rem; | ||
color: $heading-color; | ||
|
||
&:hover { | ||
color: $heading-highlight-color; | ||
} | ||
} | ||
@import "~normalize-scss/sass/normalize"; | ||
@import "~flexboxgrid-sass"; |
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,33 @@ | ||
import { Component, ViewEncapsulation, OnInit, OnDestroy } from '@angular/core'; | ||
|
||
import { ArticleService } from './article.service'; | ||
import { Article } from './article.model'; | ||
import { Response } from '@angular/http'; | ||
|
||
/** | ||
* A simple component, which fetches articles list from HTTP API and displays them. | ||
*/ | ||
@Component({ | ||
selector: 'da-article-list', | ||
templateUrl: './article-list.html', | ||
styleUrls: ['./article-list.scss'], | ||
encapsulation: ViewEncapsulation.Emulated, | ||
providers: [ArticleService] | ||
}) | ||
export class ArticleListComponent implements OnInit, OnDestroy { | ||
private articles: Article[]; | ||
private error: Response; | ||
private isLoading: boolean = true; | ||
|
||
constructor(private articleService: ArticleService) {} | ||
|
||
ngOnInit(): void { | ||
this.articleService.getAll().subscribe( | ||
(data) => this.articles = data, | ||
(error) => this.error = error, | ||
() => this.isLoading = false | ||
); | ||
} | ||
|
||
ngOnDestroy(): void {} | ||
} |
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,7 @@ | ||
<div *ngIf="isLoading"> | ||
Loading… | ||
</div> | ||
|
||
<article *ngFor="let article of articles" class="article-list-item"> | ||
<h4><a [routerLink]="['/articles', article.id]">{{ article.title }}</a></h4> | ||
</article> |
Empty file.
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,43 @@ | ||
import { Component, ViewEncapsulation, OnInit, OnDestroy } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
|
||
import { ArticleService } from './article.service'; | ||
import { Article } from './article.model'; | ||
import { Response } from '@angular/http'; | ||
|
||
/** | ||
* A simple component, which fetches article from HTTP API and displays it. | ||
*/ | ||
@Component({ | ||
selector: 'da-article', | ||
templateUrl: './article.html', | ||
styleUrls: ['./article.scss'], | ||
encapsulation: ViewEncapsulation.Emulated, | ||
providers: [ArticleService] | ||
}) | ||
export class ArticleComponent implements OnInit, OnDestroy { | ||
private article: Article; | ||
private error: Response; | ||
private isLoading: boolean = true; | ||
|
||
constructor( | ||
private route: ActivatedRoute, | ||
private articleService: ArticleService | ||
) { | ||
|
||
} | ||
|
||
/** | ||
* TODO: Note about non-observable param | ||
*/ | ||
ngOnInit(): void { | ||
let id = +this.route.snapshot.params['id']; | ||
this.articleService.get(id).subscribe( | ||
(data) => this.article = data, | ||
(error) => this.error = error, | ||
() => this.isLoading = false | ||
); | ||
} | ||
|
||
ngOnDestroy(): void {} | ||
} |
Oops, something went wrong.