├── public
└── .npmignore
├── src
├── app
│ ├── shared
│ │ └── index.ts
│ ├── article
│ │ ├── index.ts
│ │ └── article.ts
│ ├── reddit-article
│ │ ├── index.ts
│ │ ├── reddit-article.component.ts
│ │ └── reddit-article.component.spec.ts
│ ├── images
│ │ ├── favicon.ico
│ │ ├── favicon-32x32.png
│ │ └── ng-book-2-minibook.png
│ ├── index.ts
│ ├── vendor
│ │ └── themes
│ │ │ └── default
│ │ │ └── assets
│ │ │ ├── fonts
│ │ │ ├── icons.eot
│ │ │ ├── icons.otf
│ │ │ ├── icons.ttf
│ │ │ ├── icons.woff
│ │ │ └── icons.woff2
│ │ │ └── images
│ │ │ └── flags.png
│ ├── environment.ts
│ ├── angular2-reddit.component.spec.ts
│ ├── styles.css
│ └── angular2-reddit.component.ts
├── favicon.ico
├── typings.d.ts
├── main.ts
├── tsconfig.json
├── system-config.ts
└── index.html
├── e2e
├── typings.d.ts
├── app.po.ts
├── app.e2e.ts
└── tsconfig.json
├── config
├── environment.dev.ts
├── environment.prod.ts
├── environment.js
├── protractor.conf.js
├── karma-test-shim.js
└── karma.conf.js
├── .clang-format
├── .editorconfig
├── typings.json
├── .gitignore
├── angular-cli-build.js
├── angular-cli.json
├── package.json
└── tslint.json
/public/.npmignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/shared/index.ts:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/e2e/typings.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/src/app/article/index.ts:
--------------------------------------------------------------------------------
1 | export { Article } from './article';
2 |
--------------------------------------------------------------------------------
/config/environment.dev.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: false
3 | };
4 |
--------------------------------------------------------------------------------
/config/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fcoury/angular-cli-reddit/master/src/favicon.ico
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | Language: JavaScript
2 | BasedOnStyle: Google
3 | ColumnLimit: 100
4 |
--------------------------------------------------------------------------------
/src/app/reddit-article/index.ts:
--------------------------------------------------------------------------------
1 | export { RedditArticleComponent } from './reddit-article.component';
2 |
--------------------------------------------------------------------------------
/src/app/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fcoury/angular-cli-reddit/master/src/app/images/favicon.ico
--------------------------------------------------------------------------------
/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | declare var module: { id: string };
4 |
--------------------------------------------------------------------------------
/src/app/images/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fcoury/angular-cli-reddit/master/src/app/images/favicon-32x32.png
--------------------------------------------------------------------------------
/src/app/images/ng-book-2-minibook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fcoury/angular-cli-reddit/master/src/app/images/ng-book-2-minibook.png
--------------------------------------------------------------------------------
/src/app/index.ts:
--------------------------------------------------------------------------------
1 | export {environment} from './environment';
2 | export {Angular2RedditAppComponent} from './angular2-reddit.component';
3 |
--------------------------------------------------------------------------------
/src/app/vendor/themes/default/assets/fonts/icons.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fcoury/angular-cli-reddit/master/src/app/vendor/themes/default/assets/fonts/icons.eot
--------------------------------------------------------------------------------
/src/app/vendor/themes/default/assets/fonts/icons.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fcoury/angular-cli-reddit/master/src/app/vendor/themes/default/assets/fonts/icons.otf
--------------------------------------------------------------------------------
/src/app/vendor/themes/default/assets/fonts/icons.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fcoury/angular-cli-reddit/master/src/app/vendor/themes/default/assets/fonts/icons.ttf
--------------------------------------------------------------------------------
/src/app/vendor/themes/default/assets/fonts/icons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fcoury/angular-cli-reddit/master/src/app/vendor/themes/default/assets/fonts/icons.woff
--------------------------------------------------------------------------------
/src/app/vendor/themes/default/assets/fonts/icons.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fcoury/angular-cli-reddit/master/src/app/vendor/themes/default/assets/fonts/icons.woff2
--------------------------------------------------------------------------------
/src/app/vendor/themes/default/assets/images/flags.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fcoury/angular-cli-reddit/master/src/app/vendor/themes/default/assets/images/flags.png
--------------------------------------------------------------------------------
/config/environment.js:
--------------------------------------------------------------------------------
1 | /* jshint node: true */
2 |
3 | module.exports = function(environment) {
4 | return {
5 | environment: environment,
6 | baseURL: '/',
7 | locationType: 'auto'
8 | };
9 | };
10 |
11 |
--------------------------------------------------------------------------------
/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | export class Angular2RedditPage {
2 | navigateTo() {
3 | return browser.get('/');
4 | }
5 |
6 | getParagraphText() {
7 | return element(by.css('angular2-reddit-app h1')).getText();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/app/environment.ts:
--------------------------------------------------------------------------------
1 | // The file for the current environment will overwrite this one during build
2 | // Different environments can be found in config/environment.{dev|prod}.ts
3 | // The build system defaults to the dev environment
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | end_of_line = lf
9 | insert_final_newline = true
10 | trim_trailing_whitespace = true
11 |
12 | [*.md]
13 | max_line_length = 0
14 | trim_trailing_whitespace = false
15 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { bootstrap } from '@angular/platform-browser-dynamic';
2 | import { enableProdMode } from '@angular/core';
3 | import { Angular2RedditAppComponent, environment } from './app/';
4 |
5 | if (environment.production) {
6 | enableProdMode();
7 | }
8 |
9 | bootstrap(Angular2RedditAppComponent);
10 |
--------------------------------------------------------------------------------
/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ambientDevDependencies": {
3 | "angular-protractor": "registry:dt/angular-protractor#1.5.0+20160425143459",
4 | "jasmine": "registry:dt/jasmine#2.2.0+20160412134438",
5 | "selenium-webdriver": "registry:dt/selenium-webdriver#2.44.0+20160317120654"
6 | },
7 | "ambientDependencies": {
8 | "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/e2e/app.e2e.ts:
--------------------------------------------------------------------------------
1 | import { Angular2RedditPage } from './app.po';
2 |
3 | describe('angular2-reddit App', function() {
4 | let page: Angular2RedditPage;
5 |
6 | beforeEach(() => {
7 | page = new Angular2RedditPage();
8 | })
9 |
10 | it('should display message saying app works', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('angular2-reddit works!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/e2e/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "declaration": false,
5 | "emitDecoratorMetadata": true,
6 | "experimentalDecorators": true,
7 | "mapRoot": "",
8 | "module": "commonjs",
9 | "moduleResolution": "node",
10 | "noEmitOnError": true,
11 | "noImplicitAny": false,
12 | "rootDir": ".",
13 | "sourceMap": true,
14 | "sourceRoot": "/",
15 | "target": "es5"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 |
7 | # dependencies
8 | /node_modules
9 | /bower_components
10 |
11 | # IDEs and editors
12 | /.idea
13 |
14 | # misc
15 | /.sass-cache
16 | /connect.lock
17 | /coverage/*
18 | /libpeerconnection.log
19 | npm-debug.log
20 | testem.log
21 | /typings
22 |
23 | # e2e
24 | /e2e/*.js
25 | /e2e/*.map
26 |
27 | #System Files
28 | .DS_Store
--------------------------------------------------------------------------------
/angular-cli-build.js:
--------------------------------------------------------------------------------
1 | /* global require, module */
2 |
3 | var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
4 |
5 | module.exports = function(defaults) {
6 | return new Angular2App(defaults, {
7 | vendorNpmFiles: [
8 | 'systemjs/dist/system-polyfills.js',
9 | 'systemjs/dist/system.src.js',
10 | 'zone.js/dist/*.js',
11 | 'es6-shim/es6-shim.js',
12 | 'reflect-metadata/*.js',
13 | 'rxjs/**/*.js',
14 | '@angular/**/*.js'
15 | ]
16 | });
17 | };
18 |
--------------------------------------------------------------------------------
/angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "project": {
3 | "version": "1.0.0-beta.1",
4 | "name": "angular2-reddit"
5 | },
6 | "apps": [
7 | {"main": "src/main.ts", "tsconfig": "src/tsconfig.json"}
8 | ],
9 | "addons": [],
10 | "packages": [],
11 | "e2e": {
12 | "protractor": {
13 | "config": "config/protractor.conf.js"
14 | }
15 | },
16 | "test": {
17 | "karma": {
18 | "config": "config/karma.conf.js"
19 | }
20 | },
21 | "defaults": {
22 | "prefix": "app",
23 | "sourceDir": "src"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "declaration": false,
5 | "emitDecoratorMetadata": true,
6 | "experimentalDecorators": true,
7 | "mapRoot": "",
8 | "module": "commonjs",
9 | "moduleResolution": "node",
10 | "noEmitOnError": true,
11 | "noImplicitAny": false,
12 | "outDir": "../dist/",
13 | "rootDir": ".",
14 | "sourceMap": true,
15 | "target": "es5",
16 | "inlineSources": true
17 | },
18 |
19 | "files": [
20 | "main.ts",
21 | "typings.d.ts"
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/src/app/article/article.ts:
--------------------------------------------------------------------------------
1 | export class Article {
2 | title: string;
3 | link: string;
4 | votes: number;
5 |
6 | constructor(title: string, link: string, votes?: number) {
7 | this.title = title;
8 | this.link = link;
9 | this.votes = votes || 0;
10 | }
11 |
12 | domain(): string {
13 | try {
14 | const link: string = this.link.split('//')[1];
15 | return link.split('/')[0];
16 | } catch (err) {
17 | return null;
18 | }
19 | }
20 |
21 | voteUp(): void {
22 | this.votes += 1;
23 | }
24 |
25 | voteDown(): void {
26 | this.votes -= 1;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/config/protractor.conf.js:
--------------------------------------------------------------------------------
1 | /*global jasmine */
2 | var SpecReporter = require('jasmine-spec-reporter');
3 |
4 | exports.config = {
5 | allScriptsTimeout: 11000,
6 | specs: [
7 | '../e2e/**/*.e2e.ts'
8 | ],
9 | capabilities: {
10 | 'browserName': 'chrome'
11 | },
12 | directConnect: true,
13 | baseUrl: 'http://localhost:4200/',
14 | framework: 'jasmine',
15 | jasmineNodeOpts: {
16 | showColors: true,
17 | defaultTimeoutInterval: 30000,
18 | print: function() {}
19 | },
20 | useAllAngular2AppRoots: true,
21 | beforeLaunch: function() {
22 | require('ts-node').register({
23 | project: 'e2e'
24 | });
25 | },
26 | onPrepare: function() {
27 | jasmine.getEnv().addReporter(new SpecReporter());
28 | }
29 | };
30 |
--------------------------------------------------------------------------------
/src/app/angular2-reddit.component.spec.ts:
--------------------------------------------------------------------------------
1 | import {
2 | beforeEachProviders,
3 | describe,
4 | expect,
5 | it,
6 | inject
7 | } from '@angular/core/testing';
8 | import { Angular2RedditAppComponent } from '../app/angular2-reddit.component';
9 |
10 | beforeEachProviders(() => [Angular2RedditAppComponent]);
11 |
12 | describe('App: Angular2Reddit', () => {
13 | // it('should create the app',
14 | // inject([Angular2RedditAppComponent], (app: Angular2RedditAppComponent) => {
15 | // expect(app).toBeTruthy();
16 | // }));
17 | //
18 | // it('should have as title \'angular2-reddit works!\'',
19 | // inject([Angular2RedditAppComponent], (app: Angular2RedditAppComponent) => {
20 | // expect(app.title).toEqual('angular2-reddit works!');
21 | // }));
22 | });
23 |
--------------------------------------------------------------------------------
/src/app/styles.css:
--------------------------------------------------------------------------------
1 | .ui.menu .item img.logo {
2 | margin-right: 1.5em;
3 | }
4 |
5 | form.ui.segment.form {
6 | background-color: #F1F9FF;
7 | margin-top: 2em;
8 | }
9 |
10 | form.form:after {
11 | content: '';
12 | display: block;
13 | height: 0;
14 | clear: both;
15 | visibility: hidden;
16 | }
17 |
18 | .votes {
19 | display: flex;
20 | align-items: center;
21 | justify-content: center;
22 | background-color: #E6E6E6;
23 | padding: 1em 0;
24 | border-radius: 5px;
25 | }
26 |
27 | .ui.grid.posts {
28 | margin-top: 2em;
29 | }
30 |
31 | .meta {
32 | color: #9A9A9A
33 | }
34 |
35 | .ui.grid>.row>.column.votes {
36 | display: flex;
37 | }
38 |
39 | ul.ui.list li:before {
40 | content: '';
41 | }
42 |
43 | .voters {
44 | clear: both;
45 | width: 100%;
46 | }
47 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular2-reddit",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "angular-cli": {},
6 | "scripts": {
7 | "start": "ng server",
8 | "postinstall": "typings install",
9 | "lint": "tslint \"src/**/*.ts\"",
10 | "format": "clang-format -i -style=file --glob=src/**/*.ts",
11 | "pree2e": "webdriver-manager update",
12 | "e2e": "protractor"
13 | },
14 | "private": true,
15 | "dependencies": {
16 | "@angular/common": "2.0.0-rc.1",
17 | "@angular/compiler": "2.0.0-rc.1",
18 | "@angular/core": "2.0.0-rc.1",
19 | "@angular/platform-browser": "2.0.0-rc.1",
20 | "@angular/platform-browser-dynamic": "2.0.0-rc.1",
21 | "@angular/router": "2.0.0-rc.1",
22 | "es6-shim": "^0.35.0",
23 | "reflect-metadata": "0.1.3",
24 | "rxjs": "5.0.0-beta.6",
25 | "systemjs": "0.19.26",
26 | "zone.js": "^0.6.12"
27 | },
28 | "devDependencies": {
29 | "angular-cli": "^1.0.0-beta.0",
30 | "clang-format": "^1.0.35",
31 | "codelyzer": "0.0.14",
32 | "ember-cli-inject-live-reload": "^1.4.0",
33 | "jasmine-core": "^2.4.1",
34 | "jasmine-spec-reporter": "^2.4.0",
35 | "karma": "^0.13.15",
36 | "karma-chrome-launcher": "^0.2.3",
37 | "karma-jasmine": "^0.3.8",
38 | "protractor": "^3.3.0",
39 | "ts-node": "^0.5.5",
40 | "tslint": "^3.6.0",
41 | "typescript": "^1.8.10",
42 | "typings": "^0.8.1"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/app/reddit-article/reddit-article.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | import { Article } from '../article';
4 |
5 | @Component({
6 | moduleId: module.id,
7 | selector: 'reddit-article',
8 | inputs: ['article'],
9 | host: {
10 | class: 'row'
11 | },
12 | template: `
13 |
14 |
15 |
16 | {{ article.votes }}
17 |
18 |
19 | Points
20 |
21 |
22 |
23 |
24 |
27 |
({{ article.domain() }})
28 |
42 |
43 | `
44 | })
45 | export class RedditArticleComponent {
46 | article: Article;
47 |
48 | voteUp(): boolean {
49 | this.article.voteUp();
50 | return false;
51 | }
52 |
53 | voteDown(): boolean {
54 | this.article.voteDown();
55 | return false;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/config/karma-test-shim.js:
--------------------------------------------------------------------------------
1 | /*global jasmine, __karma__, window*/
2 | Error.stackTraceLimit = Infinity;
3 | jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
4 |
5 | __karma__.loaded = function () {
6 | };
7 |
8 | var distPath = '/base/dist/';
9 | var appPath = distPath + 'app/';
10 |
11 | function isJsFile(path) {
12 | return path.slice(-3) == '.js';
13 | }
14 |
15 | function isSpecFile(path) {
16 | return path.slice(-8) == '.spec.js';
17 | }
18 |
19 | function isAppFile(path) {
20 | return isJsFile(path) && (path.substr(0, appPath.length) == appPath);
21 | }
22 |
23 | var allSpecFiles = Object.keys(window.__karma__.files)
24 | .filter(isSpecFile)
25 | .filter(isAppFile);
26 |
27 | // Load our SystemJS configuration.
28 | System.config({
29 | baseURL: distPath
30 | });
31 |
32 | System.import('system-config.js').then(function() {
33 | // Load and configure the TestComponentBuilder.
34 | return Promise.all([
35 | System.import('@angular/core/testing'),
36 | System.import('@angular/platform-browser-dynamic/testing')
37 | ]).then(function (providers) {
38 | var testing = providers[0];
39 | var testingBrowser = providers[1];
40 |
41 | testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
42 | testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
43 | });
44 | }).then(function() {
45 | // Finally, load all spec files.
46 | // This will run the tests directly.
47 | return Promise.all(
48 | allSpecFiles.map(function (moduleName) {
49 | return System.import(moduleName);
50 | }));
51 | }).then(__karma__.start, __karma__.error);
--------------------------------------------------------------------------------
/config/karma.conf.js:
--------------------------------------------------------------------------------
1 | module.exports = function (config) {
2 | config.set({
3 | basePath: '..',
4 | frameworks: ['jasmine'],
5 | plugins: [
6 | require('karma-jasmine'),
7 | require('karma-chrome-launcher')
8 | ],
9 | customLaunchers: {
10 | // chrome setup for travis CI using chromium
11 | Chrome_travis_ci: {
12 | base: 'Chrome',
13 | flags: ['--no-sandbox']
14 | }
15 | },
16 | files: [
17 | { pattern: 'dist/vendor/es6-shim/es6-shim.js', included: true, watched: false },
18 | { pattern: 'dist/vendor/zone.js/dist/zone.js', included: true, watched: false },
19 | { pattern: 'dist/vendor/reflect-metadata/Reflect.js', included: true, watched: false },
20 | { pattern: 'dist/vendor/systemjs/dist/system-polyfills.js', included: true, watched: false },
21 | { pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false },
22 | { pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false },
23 |
24 | { pattern: 'config/karma-test-shim.js', included: true, watched: true },
25 |
26 | // Distribution folder.
27 | { pattern: 'dist/**/*', included: false, watched: true }
28 | ],
29 | exclude: [
30 | // Vendor packages might include spec files. We don't want to use those.
31 | 'dist/vendor/**/*.spec.js'
32 | ],
33 | preprocessors: {},
34 | reporters: ['progress'],
35 | port: 9876,
36 | colors: true,
37 | logLevel: config.LOG_INFO,
38 | autoWatch: true,
39 | browsers: ['Chrome'],
40 | singleRun: false
41 | });
42 | };
43 |
--------------------------------------------------------------------------------
/src/app/reddit-article/reddit-article.component.spec.ts:
--------------------------------------------------------------------------------
1 | import {
2 | beforeEach,
3 | beforeEachProviders,
4 | describe,
5 | expect,
6 | it,
7 | inject,
8 | } from '@angular/core/testing';
9 | import { ComponentFixture, TestComponentBuilder } from '@angular/compiler/testing';
10 | import { Component } from '@angular/core';
11 | import { By } from '@angular/platform-browser';
12 | import { RedditArticleComponent } from './reddit-article.component';
13 |
14 | describe('Component: RedditArticle', () => {
15 | // let builder: TestComponentBuilder;
16 | //
17 | // beforeEachProviders(() => [RedditArticleComponent]);
18 | // beforeEach(inject([TestComponentBuilder], function (tcb: TestComponentBuilder) {
19 | // builder = tcb;
20 | // }));
21 | //
22 | // it('should inject the component', inject([RedditArticleComponent],
23 | // (component: RedditArticleComponent) => {
24 | // expect(component).toBeTruthy();
25 | // }));
26 | //
27 | // it('should create the component', inject([], () => {
28 | // return builder.createAsync(RedditArticleComponentTestController)
29 | // .then((fixture: ComponentFixture) => {
30 | // let query = fixture.debugElement.query(By.directive(RedditArticleComponent));
31 | // expect(query).toBeTruthy();
32 | // expect(query.componentInstance).toBeTruthy();
33 | // });
34 | // }));
35 | });
36 |
37 | @Component({
38 | selector: 'test',
39 | template: `
40 |
41 | `,
42 | directives: [RedditArticleComponent]
43 | })
44 | class RedditArticleComponentTestController {
45 | }
46 |
--------------------------------------------------------------------------------
/src/app/angular2-reddit.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | import { Article } from './article';
4 | import { RedditArticleComponent } from './reddit-article';
5 |
6 | @Component({
7 | moduleId: module.id,
8 | selector: 'reddit',
9 | directives: [RedditArticleComponent],
10 | template: `
11 |
28 |
29 |
30 |
33 |
34 |
35 | `
36 | })
37 | export class Angular2RedditAppComponent {
38 | articles: Article[];
39 |
40 | constructor() {
41 | this.articles = [
42 | new Article('Angular 2', 'http://angular.io', 3),
43 | new Article('Fullstack', 'http://fullstack.io', 2),
44 | new Article('Angular Homepage', 'http://angular.io', 1),
45 | ];
46 | }
47 |
48 | addArticle(title: HTMLInputElement, link: HTMLInputElement): void {
49 | console.log(`Adding article title: ${title.value} and link: ${link.value}`);
50 | this.articles.push(new Article(title.value, link.value, 0));
51 | title.value = '';
52 | link.value = '';
53 | }
54 |
55 | sortedArticles(): Article[] {
56 | return this.articles.sort((a: Article, b: Article) => b.votes - a.votes);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/system-config.ts:
--------------------------------------------------------------------------------
1 | /***********************************************************************************************
2 | * User Configuration.
3 | **********************************************************************************************/
4 | /** Map relative paths to URLs. */
5 | const map: any = {
6 | };
7 |
8 | /** User packages configuration. */
9 | const packages: any = {
10 | };
11 |
12 | ////////////////////////////////////////////////////////////////////////////////////////////////
13 | /***********************************************************************************************
14 | * Everything underneath this line is managed by the CLI.
15 | **********************************************************************************************/
16 | const barrels: string[] = [
17 | // Angular specific barrels.
18 | '@angular/core',
19 | '@angular/common',
20 | '@angular/compiler',
21 | '@angular/http',
22 | '@angular/router',
23 | '@angular/platform-browser',
24 | '@angular/platform-browser-dynamic',
25 |
26 | // Thirdparty barrels.
27 | 'rxjs',
28 |
29 | // App specific barrels.
30 | 'app',
31 | 'app/article',
32 | 'app/shared',
33 | 'app/reddit-article',
34 | 'app/reddit',
35 | /** @cli-barrel */
36 | ];
37 |
38 | const cliSystemConfigPackages: any = {};
39 | barrels.forEach((barrelName: string) => {
40 | cliSystemConfigPackages[barrelName] = { main: 'index' };
41 | });
42 |
43 | /** Type declaration for ambient System. */
44 | declare var System: any;
45 |
46 | // Apply the CLI SystemJS configuration.
47 | System.config({
48 | map: {
49 | '@angular': 'vendor/@angular',
50 | 'rxjs': 'vendor/rxjs',
51 | 'main': 'main.js'
52 | },
53 | packages: cliSystemConfigPackages
54 | });
55 |
56 | // Apply the user's configuration.
57 | System.config({ map, packages });
58 |
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Angular2Reddit
6 |
7 | {{content-for 'head'}}
8 |
9 |
10 |
11 |
22 |
23 |
24 |
25 |
26 |
39 |
40 |
41 | Loading...
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": ["node_modules/codelyzer"],
3 | "rules": {
4 | "max-line-length": [true, 100],
5 | "no-inferrable-types": true,
6 | "class-name": true,
7 | "comment-format": [
8 | true,
9 | "check-space"
10 | ],
11 | "indent": [
12 | true,
13 | "spaces"
14 | ],
15 | "eofline": true,
16 | "no-duplicate-variable": true,
17 | "no-eval": true,
18 | "no-arg": true,
19 | "no-internal-module": true,
20 | "no-trailing-whitespace": true,
21 | "no-bitwise": true,
22 | "no-shadowed-variable": true,
23 | "no-unused-expression": true,
24 | "no-unused-variable": true,
25 | "one-line": [
26 | true,
27 | "check-catch",
28 | "check-else",
29 | "check-open-brace",
30 | "check-whitespace"
31 | ],
32 | "quotemark": [
33 | true,
34 | "single",
35 | "avoid-escape"
36 | ],
37 | "semicolon": [true, "always"],
38 | "typedef-whitespace": [
39 | true,
40 | {
41 | "call-signature": "nospace",
42 | "index-signature": "nospace",
43 | "parameter": "nospace",
44 | "property-declaration": "nospace",
45 | "variable-declaration": "nospace"
46 | }
47 | ],
48 | "curly": true,
49 | "variable-name": [
50 | true,
51 | "ban-keywords",
52 | "check-format",
53 | "allow-trailing-underscore"
54 | ],
55 | "whitespace": [
56 | true,
57 | "check-branch",
58 | "check-decl",
59 | "check-operator",
60 | "check-separator",
61 | "check-type"
62 | ],
63 | "component-selector-name": [true, "kebab-case"],
64 | "component-selector-type": [true, "element"],
65 | "host-parameter-decorator": true,
66 | "input-parameter-decorator": true,
67 | "output-parameter-decorator": true,
68 | "attribute-parameter-decorator": true,
69 | "input-property-directive": true,
70 | "output-property-directive": true
71 | }
72 | }
73 |
--------------------------------------------------------------------------------