├── .gitignore ├── .vscode └── settings.json ├── README.md ├── angular.json ├── package-lock.json ├── package.json ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── feature │ │ ├── feature.component.html │ │ └── feature.component.ts │ ├── home │ │ ├── home.component.html │ │ └── home.component.ts │ ├── main.ts │ └── shared │ │ └── data.service.ts ├── assets │ ├── .gitkeep │ └── styles │ │ └── styles.css ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.css ├── tsconfig.app.json └── typings.d.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | testem.log 34 | /typings 35 | 36 | # e2e 37 | /e2e/*.js 38 | /e2e/*.map 39 | 40 | # System Files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "**/app/**/*.js.map": true, 5 | "**/app/**/*.js": true 6 | } 7 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Angular and TypeScript Bare Bones Project 2 | 3 | The Bare Bones project is an Angular starter project that has the npm modules, 4 | configuration, scripts, folders and routing in place. 5 | 6 | Here's what is in the project: 7 | 8 | * Angular scripts and TypeScript configuration are ready to go 9 | * Angular bootstrapper wired up to the app component 10 | * App component with basic routing applied 11 | * Homepage component 12 | * A single "feature" component (represents a custom feature your app would have) 13 | * A simple data service to provide data and show dependency injection 14 | * Routing between the homepage and the "feature" 15 | * Bootstrap for CSS 16 | 17 | It's a minimal app intended to get you up and running quickly so the rest is up to you! 18 | 19 | If you're using VS Code, install my [Angular code snippets](https://blog.codewithdan.com/2017/04/01/angular-2-typescript-and-html-snippets-for-vs-code/) 20 | to simplify the process of writing Angular code. The code snippets make it easy 21 | to build Angular components, services, pipes, directives and more. 22 | 23 | 24 | ## Running the Application 25 | 26 | 1. Install [Node.js](http://nodejs.org) 27 | 28 | 1. Install the Angular CLI: 29 | 30 | `npm install -g @angular/cli` 31 | 32 | 1. Run `npm install` to install app dependencies 33 | 34 | 1. Run `ng serve -o` to start the server and launch the app 35 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "angular-bare-bones": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "architect": { 11 | "build": { 12 | "builder": "@angular-devkit/build-angular:browser", 13 | "options": { 14 | "outputPath": "dist", 15 | "index": "src/index.html", 16 | "main": "src/main.ts", 17 | "tsConfig": "src/tsconfig.app.json", 18 | "polyfills": "src/polyfills.ts", 19 | "assets": [ 20 | "src/assets", 21 | "src/favicon.ico" 22 | ], 23 | "styles": [ 24 | "src/styles.css" 25 | ], 26 | "scripts": [] 27 | }, 28 | "configurations": { 29 | "production": { 30 | "optimization": true, 31 | "outputHashing": "all", 32 | "sourceMap": false, 33 | "extractCss": true, 34 | "namedChunks": false, 35 | "aot": true, 36 | "extractLicenses": true, 37 | "vendorChunk": false, 38 | "buildOptimizer": true, 39 | "fileReplacements": [ 40 | { 41 | "replace": "src/environments/environment.ts", 42 | "with": "src/environments/environment.prod.ts" 43 | } 44 | ] 45 | } 46 | } 47 | }, 48 | "serve": { 49 | "builder": "@angular-devkit/build-angular:dev-server", 50 | "options": { 51 | "browserTarget": "angular-bare-bones:build" 52 | }, 53 | "configurations": { 54 | "production": { 55 | "browserTarget": "angular-bare-bones:build:production" 56 | } 57 | } 58 | }, 59 | "extract-i18n": { 60 | "builder": "@angular-devkit/build-angular:extract-i18n", 61 | "options": { 62 | "browserTarget": "angular-bare-bones:build" 63 | } 64 | }, 65 | "test": { 66 | "builder": "@angular-devkit/build-angular:karma", 67 | "options": { 68 | "main": "src/test.ts", 69 | "karmaConfig": "./karma.conf.js", 70 | "polyfills": "src/polyfills.ts", 71 | "tsConfig": "src/tsconfig.spec.json", 72 | "scripts": [], 73 | "styles": [ 74 | "src/styles.css" 75 | ], 76 | "assets": [ 77 | "src/assets", 78 | "src/favicon.ico" 79 | ] 80 | } 81 | }, 82 | "lint": { 83 | "builder": "@angular-devkit/build-angular:tslint", 84 | "options": { 85 | "tsConfig": [ 86 | "src/tsconfig.app.json", 87 | "src/tsconfig.spec.json" 88 | ], 89 | "exclude": [ 90 | "**/node_modules/**" 91 | ] 92 | } 93 | } 94 | } 95 | }, 96 | "angular-bare-bones-e2e": { 97 | "root": "", 98 | "sourceRoot": "", 99 | "projectType": "application", 100 | "architect": { 101 | "e2e": { 102 | "builder": "@angular-devkit/build-angular:protractor", 103 | "options": { 104 | "protractorConfig": "./protractor.conf.js", 105 | "devServerTarget": "angular-bare-bones:serve" 106 | } 107 | }, 108 | "lint": { 109 | "builder": "@angular-devkit/build-angular:tslint", 110 | "options": { 111 | "tsConfig": [ 112 | "e2e/tsconfig.e2e.json" 113 | ], 114 | "exclude": [ 115 | "**/node_modules/**" 116 | ] 117 | } 118 | } 119 | } 120 | } 121 | }, 122 | "defaultProject": "angular-bare-bones", 123 | "schematics": { 124 | "@schematics/angular:class": { 125 | "spec": false 126 | }, 127 | "@schematics/angular:component": { 128 | "inlineStyle": true, 129 | "inlineTemplate": true, 130 | "spec": false, 131 | "prefix": "app", 132 | "styleext": "css" 133 | }, 134 | "@schematics/angular:directive": { 135 | "spec": false, 136 | "prefix": "app" 137 | }, 138 | "@schematics/angular:guard": { 139 | "spec": false 140 | }, 141 | "@schematics/angular:module": { 142 | "spec": false 143 | }, 144 | "@schematics/angular:pipe": { 145 | "spec": false 146 | }, 147 | "@schematics/angular:service": { 148 | "spec": false 149 | } 150 | } 151 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-bare-bones", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "ng": "ng", 7 | "start": "ng serve", 8 | "build": "ng build", 9 | "test": "ng test", 10 | "lint": "ng lint", 11 | "e2e": "ng e2e" 12 | }, 13 | "private": true, 14 | "dependencies": { 15 | "@angular/animations": "^7.0.0", 16 | "@angular/common": "^7.0.0", 17 | "@angular/compiler": "^7.0.0", 18 | "@angular/core": "^7.0.0", 19 | "@angular/forms": "^7.0.0", 20 | "@angular/http": "^7.0.0", 21 | "@angular/platform-browser": "^7.0.0", 22 | "@angular/platform-browser-dynamic": "^7.0.0", 23 | "@angular/router": "^7.0.0", 24 | "core-js": "^2.5.7", 25 | "rxjs": "^6.3.3", 26 | "zone.js": "^0.8.26" 27 | }, 28 | "devDependencies": { 29 | "@angular/cli": "^7.0.2", 30 | "@angular/compiler-cli": "^7.0.0", 31 | "@angular/language-service": "^7.0.0", 32 | "typescript": "3.1.3", 33 | "@angular-devkit/build-angular": "~0.10.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | import { HomeComponent } from './home/home.component'; 5 | import { FeatureComponent } from './feature/feature.component'; 6 | 7 | const routes: Routes = [ 8 | { path: '', pathMatch:'full', redirectTo: '/home' }, 9 | { path: 'home', component: HomeComponent }, 10 | { path: 'feature', component: FeatureComponent } 11 | ]; 12 | 13 | @NgModule({ 14 | imports: [RouterModule.forRoot(routes)], 15 | exports: [RouterModule] 16 | }) 17 | export class AppRoutingModule { 18 | static components = [ HomeComponent, FeatureComponent ]; 19 | } 20 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | template: `` 6 | }) 7 | export class AppComponent { 8 | 9 | constructor() { } 10 | 11 | } -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { HttpModule} from '@angular/http'; 5 | 6 | import { AppComponent } from './app.component'; 7 | import { AppRoutingModule } from './app-routing.module'; 8 | import { DataService } from './shared/data.service'; 9 | 10 | @NgModule({ 11 | imports: [ BrowserModule, FormsModule, HttpModule, AppRoutingModule ], 12 | declarations: [ AppComponent, AppRoutingModule.components ], 13 | providers: [ DataService ], 14 | bootstrap: [ AppComponent ] 15 | }) 16 | export class AppModule { } -------------------------------------------------------------------------------- /src/app/feature/feature.component.html: -------------------------------------------------------------------------------- 1 |

Application Feature!

2 |
3 | Back to Home -------------------------------------------------------------------------------- /src/app/feature/feature.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'feature', 5 | templateUrl: './feature.component.html' 6 | }) 7 | export class FeatureComponent implements OnInit { 8 | 9 | constructor() { } 10 | 11 | ngOnInit() { 12 | 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /src/app/home/home.component.html: -------------------------------------------------------------------------------- 1 |

{{ projectName }} Project Loaded!

2 |
3 | Navigate to application "feature" 4 |
5 |
6 |
7 | You can get my Angular snippets for the VS Code editor here. -------------------------------------------------------------------------------- /src/app/home/home.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | import { DataService } from '../shared/data.service'; 4 | 5 | @Component({ 6 | selector: 'home', 7 | templateUrl: './home.component.html' 8 | }) 9 | export class HomeComponent implements OnInit { 10 | 11 | projectName: string; 12 | 13 | constructor(private dataService: DataService) { } 14 | 15 | ngOnInit() { 16 | this.projectName = this.dataService.getProjectName(); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /src/app/main.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 2 | import { AppModule } from './app.module'; 3 | import { enableProdMode } from '@angular/core'; 4 | 5 | //enableProdMode(); //Uncomment for production 6 | platformBrowserDynamic().bootstrapModule(AppModule) 7 | .then((success: any) => console.log('App bootstrapped')) 8 | .catch((err: any) => console.error(err)); -------------------------------------------------------------------------------- /src/app/shared/data.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable() 4 | export class DataService { 5 | 6 | constructor() { } 7 | 8 | getProjectName() { 9 | return 'Angular Bare Bones'; 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DanWahlin/Angular-BareBones/09ec870d72db056ed60f78c169dde272682278db/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/assets/styles/styles.css: -------------------------------------------------------------------------------- 1 | html { 2 | overflow-y: scroll; 3 | overflow-x: hidden; 4 | } 5 | 6 | main { 7 | position: relative; 8 | padding-top: 60px; 9 | } 10 | 11 | /* Ensure display:flex and others don't override a [hidden] */ 12 | [hidden] { display: none !important; } 13 | 14 | .navbar-inner { 15 | padding-left: 0px; 16 | -webkit-border-radius: 0px; 17 | border-radius: 0px; 18 | -webkit-box-shadow: none; 19 | -moz-box-shadow: none; 20 | box-shadow: none; 21 | background-color: #027FF4; 22 | background-image: none; 23 | } 24 | 25 | .navbar-inner.toolbar { 26 | background-color: #fafafa; 27 | } 28 | 29 | footer { 30 | margin-top: 15px; 31 | } 32 | 33 | .navbar-inner.footer { 34 | background-color: #fafafa; 35 | -webkit-box-shadow: none; 36 | -moz-box-shadow: none; 37 | box-shadow: none; 38 | height:50px; 39 | } 40 | 41 | .nav.navBarPadding { 42 | margin-left:25px; 43 | margin-top: 10px; 44 | } 45 | 46 | .navbar .brand { 47 | margin-top: 2px; 48 | color: #fff; 49 | -webkit-text-shadow: none; 50 | text-shadow: none; 51 | } 52 | 53 | .navbar-toggle { 54 | border: 1px solid white; 55 | } 56 | 57 | .navbar-toggle .icon-bar { 58 | background-color: white; 59 | } 60 | 61 | .app-title { 62 | line-height:50px; 63 | font-size:20px; 64 | color: white; 65 | } -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | 6 | export const environment = { 7 | production: false 8 | }; 9 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DanWahlin/Angular-BareBones/09ec870d72db056ed60f78c169dde272682278db/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | Angular Bare Bones Project 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 29 | 30 |
31 | 32 | Loading... 33 | 34 |

35 |
36 | 37 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** IE10 and IE11 requires the following for the Reflect API. */ 41 | // import 'core-js/es6/reflect'; 42 | 43 | 44 | /** Evergreen browsers require these. **/ 45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 46 | 47 | 48 | 49 | /** 50 | * Required to support Web Animations `@angular/platform-browser/animations`. 51 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 52 | **/ 53 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 54 | 55 | 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by Angular itself. 59 | */ 60 | import 'zone.js/dist/zone'; // Included with Angular CLI. 61 | 62 | 63 | 64 | /*************************************************************************************************** 65 | * APPLICATION IMPORTS 66 | */ 67 | 68 | /** 69 | * Date, currency, decimal and percent pipes. 70 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 71 | */ 72 | // import 'intl'; // Run `npm install --save intl`. 73 | /** 74 | * Need to import at least one locale-data with intl. 75 | */ 76 | // import 'intl/locale-data/jsonp/en'; 77 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "baseUrl": "./", 6 | "module": "es2015", 7 | "types": [] 8 | }, 9 | "exclude": [ 10 | "test.ts", 11 | "**/*.spec.ts" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /* SystemJS module definition */ 2 | declare var module: NodeModule; 3 | interface NodeModule { 4 | id: string; 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "target": "es5", 11 | "typeRoots": [ 12 | "node_modules/@types" 13 | ], 14 | "lib": [ 15 | "es2017", 16 | "dom" 17 | ] 18 | } 19 | } 20 | --------------------------------------------------------------------------------