;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [AdminComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(AdminComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/admin/admin.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-admin',
5 | templateUrl: './admin.component.html',
6 | styleUrls: ['./admin.component.scss']
7 | })
8 | export class AdminComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/admin/admin.module.spec.ts:
--------------------------------------------------------------------------------
1 | import { AdminModule } from './admin.module';
2 |
3 | describe('AdminModule', () => {
4 | let adminModule: AdminModule;
5 |
6 | beforeEach(() => {
7 | adminModule = new AdminModule();
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/src/app/admin/admin.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { AdminRoutingModule } from './admin-routing.module';
5 | import { AdminComponent } from './admin.component';
6 | import { DashboardComponent } from './dashboard/dashboard.component';
7 |
8 | @NgModule({
9 | imports: [
10 | CommonModule,
11 | AdminRoutingModule
12 | ],
13 | declarations: [AdminComponent, DashboardComponent]
14 | })
15 | export class AdminModule { }
16 |
--------------------------------------------------------------------------------
/src/app/admin/dashboard/dashboard.component.html:
--------------------------------------------------------------------------------
1 |
2 | Welcome to the Admin dashboard!
3 |
4 |
5 | The Authentication Guard in the Core Module will only allow you access this route if you have logged in.
6 |
--------------------------------------------------------------------------------
/src/app/admin/dashboard/dashboard.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaarheed/angular6-starter-multi-module/0e9655794fcb34389e2beaedca70362f8bf3aa21/src/app/admin/dashboard/dashboard.component.scss
--------------------------------------------------------------------------------
/src/app/admin/dashboard/dashboard.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DashboardComponent } from './dashboard.component';
4 |
5 | describe('DashboardComponent', () => {
6 | let component: DashboardComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [DashboardComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DashboardComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/admin/dashboard/dashboard.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-dashboard',
5 | templateUrl: './dashboard.component.html',
6 | styleUrls: ['./dashboard.component.scss']
7 | })
8 | export class DashboardComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/app/app.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaarheed/angular6-starter-multi-module/0e9655794fcb34389e2beaedca70362f8bf3aa21/src/app/app.component.scss
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 | describe('AppComponent', () => {
4 | beforeEach(async(() => {
5 | TestBed.configureTestingModule({
6 | declarations: [
7 | AppComponent
8 | ],
9 | }).compileComponents();
10 | }));
11 |
12 |
13 | });
14 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.scss']
7 | })
8 | export class AppComponent {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { AppComponent } from './app.component';
5 | import { CoreModule } from './core/core.module';
6 |
7 | @NgModule({
8 | declarations: [
9 | AppComponent
10 | ],
11 | imports: [
12 | BrowserModule,
13 | CoreModule
14 | ],
15 | providers: [],
16 | bootstrap: [AppComponent]
17 | })
18 | export class AppModule { }
19 |
--------------------------------------------------------------------------------
/src/app/core/core-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { NotFoundComponent } from './not-found/not-found.component';
4 | import { AuthGuardService } from './services/auth-guard.service';
5 | import { LoginComponent } from './login/login.component';
6 |
7 | const routes: Routes = [
8 | {
9 | path: '',
10 | redirectTo: 'form',
11 | pathMatch: 'full'
12 | },
13 | {
14 | path: 'login',
15 | component: LoginComponent
16 | },
17 | {
18 | path: 'admin',
19 | canActivate: [AuthGuardService],
20 | loadChildren: '../admin/admin.module#AdminModule'
21 | },
22 | {
23 | path: 'form',
24 | loadChildren: '../form/form.module#FormModule'
25 | },
26 | {
27 | path: '**',
28 | component: NotFoundComponent
29 | }
30 | ];
31 |
32 | @NgModule({
33 | imports: [RouterModule.forRoot(routes)],
34 | exports: [RouterModule]
35 | })
36 | export class CoreRoutingModule { }
37 |
--------------------------------------------------------------------------------
/src/app/core/core.module.spec.ts:
--------------------------------------------------------------------------------
1 | import { CoreModule } from './core.module';
2 |
3 | describe('CoreModule', () => {
4 | let coreModule: CoreModule;
5 |
6 | beforeEach(() => {
7 | coreModule = new CoreModule();
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/src/app/core/core.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { CoreRoutingModule } from './core-routing.module';
5 | import { LoginComponent } from './login/login.component';
6 | import { HeaderComponent } from './header/header.component';
7 | import { NotFoundComponent } from './not-found/not-found.component';
8 | import { RouterModule } from '@angular/router';
9 | import { AuthenticationService } from './services/authentication.service';
10 | import { AuthGuardService } from './services/auth-guard.service';
11 |
12 | @NgModule({
13 | imports: [
14 | CommonModule,
15 | CoreRoutingModule
16 | ],
17 | declarations: [LoginComponent, HeaderComponent, NotFoundComponent],
18 | exports: [
19 | RouterModule,
20 | HeaderComponent
21 | ],
22 | providers: [
23 | AuthenticationService,
24 | AuthGuardService
25 | ]
26 | })
27 | export class CoreModule { }
28 |
--------------------------------------------------------------------------------
/src/app/core/header/header.component.html:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/src/app/core/header/header.component.scss:
--------------------------------------------------------------------------------
1 | div#header {
2 | width: 100%;
3 | background: #5d5d5d;
4 | padding: 15px;
5 | color: #ffffff;
6 |
7 | a {
8 | color: #ffffff;
9 | text-decoration: underline;
10 | margin-left: 7px;
11 | }
12 | }
--------------------------------------------------------------------------------
/src/app/core/header/header.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { HeaderComponent } from './header.component';
4 |
5 | describe('HeaderComponent', () => {
6 | let component: HeaderComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [HeaderComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(HeaderComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/core/header/header.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { AuthenticationService } from '../services/authentication.service';
3 |
4 | @Component({
5 | selector: 'app-header',
6 | templateUrl: './header.component.html',
7 | styleUrls: ['./header.component.scss']
8 | })
9 | export class HeaderComponent implements OnInit {
10 |
11 | constructor(private authentication: AuthenticationService) { }
12 |
13 | ngOnInit() {
14 | }
15 |
16 | logout() {
17 | this.authentication.logout();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/app/core/login/login.component.html:
--------------------------------------------------------------------------------
1 |
9 |
--------------------------------------------------------------------------------
/src/app/core/login/login.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaarheed/angular6-starter-multi-module/0e9655794fcb34389e2beaedca70362f8bf3aa21/src/app/core/login/login.component.scss
--------------------------------------------------------------------------------
/src/app/core/login/login.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { LoginComponent } from './login.component';
4 |
5 | describe('LoginComponent', () => {
6 | let component: LoginComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [LoginComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(LoginComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/core/login/login.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { AuthenticationService } from '../services/authentication.service';
3 | import { Router } from '@angular/router';
4 |
5 | @Component({
6 | selector: 'app-login',
7 | templateUrl: './login.component.html',
8 | styleUrls: ['./login.component.scss']
9 | })
10 | export class LoginComponent implements OnInit {
11 |
12 | constructor(private authentication: AuthenticationService, private router: Router) { }
13 |
14 | ngOnInit() {
15 | }
16 |
17 | login(username, password) {
18 | this.authentication.login(username, password);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/core/not-found/not-found.component.html:
--------------------------------------------------------------------------------
1 |
2 | not-found works!
3 |
4 |
--------------------------------------------------------------------------------
/src/app/core/not-found/not-found.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaarheed/angular6-starter-multi-module/0e9655794fcb34389e2beaedca70362f8bf3aa21/src/app/core/not-found/not-found.component.scss
--------------------------------------------------------------------------------
/src/app/core/not-found/not-found.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { NotFoundComponent } from './not-found.component';
4 |
5 | describe('NotFoundComponent', () => {
6 | let component: NotFoundComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [NotFoundComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(NotFoundComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/core/not-found/not-found.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-not-found',
5 | templateUrl: './not-found.component.html',
6 | styleUrls: ['./not-found.component.scss']
7 | })
8 | export class NotFoundComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/core/services/api-interceptor.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { ApiInterceptorService } from './api-interceptor.service';
4 |
5 | describe('ApiInterceptorService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [ApiInterceptorService]
9 | });
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/src/app/core/services/api-interceptor.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable, Injector } from '@angular/core';
2 | import { Router } from '@angular/router';
3 | import { HttpHandler, HttpRequest, HttpEvent, HttpResponse, HttpErrorResponse, HttpInterceptor } from "@angular/common/http";
4 | import { Observable } from 'rxjs/Rx';
5 | import { environment } from '../../../environments/environment';
6 | import { AuthenticationService } from './authentication.service';
7 |
8 | @Injectable()
9 | export class ApiInterceptorService {
10 |
11 | constructor(private injector: Injector, private router: Router) { }
12 |
13 | intercept(request: HttpRequest, next: HttpHandler): Observable> {
14 | return next.handle(request);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/app/core/services/auth-guard.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { AuthGuardService } from './auth-guard.service';
4 |
5 | describe('AuthGuardService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [AuthGuardService]
9 | });
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/src/app/core/services/auth-guard.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { AuthenticationService } from './authentication.service';
3 | import { Router } from '@angular/router';
4 |
5 | @Injectable()
6 | export class AuthGuardService {
7 |
8 | constructor(private authentication: AuthenticationService, private router: Router) { }
9 |
10 | canActivate(): boolean | Promise {
11 | let token = this.authentication.getToken();
12 | let accessToken = this.authentication.getAccessToken();
13 |
14 | if (!token) {
15 | console.error("User is not authenticated.");
16 | this.redirectToLoginPage();
17 | return false;
18 | }
19 | else if (this.authentication.isAuthenticated()) {
20 | return true;
21 | }
22 | else {
23 | this.authentication.refreshToken();
24 | return true;
25 | }
26 | }
27 |
28 | redirectToLoginPage() {
29 | this.router.navigate(['/login']);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/app/core/services/authentication.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { AuthenticationService } from './authentication.service';
4 |
5 | describe('AuthenticationService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [AuthenticationService]
9 | });
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/src/app/core/services/authentication.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { Router } from '@angular/router';
3 |
4 | @Injectable()
5 | export class AuthenticationService {
6 | token = {
7 | refresh_token: 'refreshtokencode',
8 | exp: new Date((new Date().getDate() + 1)),
9 | access_token: {
10 | username: 'user',
11 | roles: ['Admin', 'RegisteredUser', 'Super User']
12 | }
13 | };
14 |
15 | tokenKey: string = "a6smm_utoken"
16 |
17 | constructor(private router: Router) { }
18 |
19 | login(username, password) {
20 | this.setToken(this.token);
21 | this.router.navigate(['admin', 'dashboard']);
22 | }
23 |
24 | logout() {
25 | this.removeToken();
26 | this.router.navigate(['login']);
27 | }
28 |
29 | getToken() {
30 | return JSON.parse(localStorage.getItem(this.tokenKey));
31 | }
32 |
33 | setToken(token) {
34 | localStorage.setItem(this.tokenKey, JSON.stringify(token));
35 | }
36 |
37 | getAccessToken() {
38 | return JSON.parse(localStorage.getItem(this.tokenKey))['access_token'];
39 | }
40 |
41 | isAuthenticated() {
42 | let token = localStorage.getItem(this.tokenKey);
43 |
44 | if (token) {
45 | return true;
46 | }
47 | else {
48 | return false;
49 | }
50 | }
51 |
52 | refreshToken() {
53 | this.token.exp = new Date((new Date().getDate() + 1));
54 | this.setToken(this.token);
55 | }
56 |
57 | removeToken() {
58 | localStorage.removeItem(this.tokenKey);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/app/form/form-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { FormComponent } from './form.component';
4 |
5 | const routes: Routes = [
6 | { path: '', component: FormComponent }
7 | ];
8 |
9 | @NgModule({
10 | imports: [RouterModule.forChild(routes)],
11 | exports: [RouterModule]
12 | })
13 | export class FormRoutingModule { }
14 |
--------------------------------------------------------------------------------
/src/app/form/form.component.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/app/form/form.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaarheed/angular6-starter-multi-module/0e9655794fcb34389e2beaedca70362f8bf3aa21/src/app/form/form.component.scss
--------------------------------------------------------------------------------
/src/app/form/form.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { FormComponent } from './form.component';
4 |
5 | describe('FormComponent', () => {
6 | let component: FormComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [FormComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(FormComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/form/form.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-form',
5 | templateUrl: './form.component.html',
6 | styleUrls: ['./form.component.scss']
7 | })
8 | export class FormComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/form/form.module.spec.ts:
--------------------------------------------------------------------------------
1 | import { FormModule } from './form.module';
2 |
3 | describe('FormModule', () => {
4 | let formModule: FormModule;
5 |
6 | beforeEach(() => {
7 | formModule = new FormModule();
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/src/app/form/form.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { FormRoutingModule } from './form-routing.module';
5 | import { FormComponent } from './form.component';
6 | import { RecentSubmissionsComponent } from './recent-submissions/recent-submissions.component';
7 | import { NewSubmissionComponent } from './new-submission/new-submission.component';
8 | import { SharedModule } from '../shared/shared.module';
9 |
10 | @NgModule({
11 | imports: [
12 | CommonModule,
13 | FormRoutingModule,
14 | SharedModule
15 | ],
16 | declarations: [FormComponent, RecentSubmissionsComponent, NewSubmissionComponent]
17 | })
18 | export class FormModule { }
19 |
--------------------------------------------------------------------------------
/src/app/form/new-submission/new-submission.component.html:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/src/app/form/new-submission/new-submission.component.scss:
--------------------------------------------------------------------------------
1 | form {
2 | margin-top: 15px;
3 | }
4 |
5 | label.required:before {
6 | content: "*";
7 | color: red;
8 | font-weight: 700;
9 | font-size: 20px;
10 | vertical-align: top;
11 | line-height: 1;
12 | }
--------------------------------------------------------------------------------
/src/app/form/new-submission/new-submission.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { NewSubmissionComponent } from './new-submission.component';
4 |
5 | describe('NewSubmissionComponent', () => {
6 | let component: NewSubmissionComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [NewSubmissionComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(NewSubmissionComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | });
23 |
--------------------------------------------------------------------------------
/src/app/form/new-submission/new-submission.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-new-submission',
5 | templateUrl: './new-submission.component.html',
6 | styleUrls: ['./new-submission.component.scss']
7 | })
8 | export class NewSubmissionComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/form/recent-submissions/recent-submissions.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Name |
4 | Email |
5 |
6 |
7 | {{submission.name}} |
8 | {{submission.email}} |
9 |
10 |
--------------------------------------------------------------------------------
/src/app/form/recent-submissions/recent-submissions.component.scss:
--------------------------------------------------------------------------------
1 | table, th, td {
2 | border: 1px solid black;
3 | margin-top: 15px;
4 | padding: 5px;
5 | }
--------------------------------------------------------------------------------
/src/app/form/recent-submissions/recent-submissions.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { RecentSubmissionsComponent } from './recent-submissions.component';
4 |
5 | describe('RecentSubmissionsComponent', () => {
6 | let component: RecentSubmissionsComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [RecentSubmissionsComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(RecentSubmissionsComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/form/recent-submissions/recent-submissions.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-recent-submissions',
5 | templateUrl: './recent-submissions.component.html',
6 | styleUrls: ['./recent-submissions.component.scss']
7 | })
8 | export class RecentSubmissionsComponent implements OnInit {
9 | submissions: Array<{}>;
10 |
11 | constructor() { }
12 |
13 | ngOnInit() {
14 | this.initSubmissions();
15 | }
16 |
17 | initSubmissions() {
18 | this.submissions = [
19 | { name: 'John', email: 'john@angular6-starter-multi-module.com' },
20 | { name: 'Samantha', email: 'sam@angular6-starter-multi-module.com' },
21 | { name: 'Cassandra', email: 'cass@angular6-starter-multi-module.com' },
22 | { name: 'Taylor', email: 'taylor@angular6-starter-multi-module.com' },
23 | { name: 'Fatima', email: 'fatima@angular6-starter-multi-module.com' }
24 | ]
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/app/shared/directives/required-label.directive.spec.ts:
--------------------------------------------------------------------------------
1 | import { RequiredLabelDirective } from './required-label.directive';
2 |
3 | describe('RequiredLabelDirective', () => {
4 |
5 | });
6 |
--------------------------------------------------------------------------------
/src/app/shared/directives/required-label.directive.ts:
--------------------------------------------------------------------------------
1 | import { Directive, ElementRef, Renderer2 } from '@angular/core';
2 |
3 | @Directive({
4 | selector: '[requiredLabel]'
5 | })
6 | export class RequiredLabelDirective {
7 |
8 | constructor(private element: ElementRef, private renderer: Renderer2) {
9 | this.renderer.addClass(this.element.nativeElement, "required");
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/app/shared/shared.module.spec.ts:
--------------------------------------------------------------------------------
1 | import { SharedModule } from './shared.module';
2 |
3 | describe('SharedModule', () => {
4 | let sharedModule: SharedModule;
5 |
6 | beforeEach(() => {
7 | sharedModule = new SharedModule();
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/src/app/shared/shared.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { RequiredLabelDirective } from './directives/required-label.directive';
4 |
5 | @NgModule({
6 | imports: [
7 | CommonModule
8 | ],
9 | declarations: [RequiredLabelDirective],
10 | exports: [
11 | RequiredLabelDirective
12 | ]
13 | })
14 | export class SharedModule { }
15 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaarheed/angular6-starter-multi-module/0e9655794fcb34389e2beaedca70362f8bf3aa21/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true,
3 | apiBasePath: 'localhost:4201'
4 | };
5 |
--------------------------------------------------------------------------------
/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/zaarheed/angular6-starter-multi-module/0e9655794fcb34389e2beaedca70362f8bf3aa21/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Angular6StarterMultiModule
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/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 | import 'core-js/es7/reflect';
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.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 | body {
3 | margin: 0;
4 | padding: 0;
5 | font-family: Verdana, Geneva, Tahoma, sans-serif;
6 | }
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare const __karma__: any;
17 | declare const require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () { };
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/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/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts",
15 | "polyfills.ts"
16 | ],
17 | "include": [
18 | "**/*.spec.ts",
19 | "**/*.d.ts"
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "eofline": true,
15 | "forin": true,
16 | "import-blacklist": [
17 | true,
18 | "rxjs/Rx"
19 | ],
20 | "import-spacing": true,
21 | "indent": [
22 | true,
23 | "spaces"
24 | ],
25 | "interface-over-type-literal": true,
26 | "label-position": true,
27 | "max-line-length": [
28 | true,
29 | 140
30 | ],
31 | "member-access": false,
32 | "member-ordering": [
33 | true,
34 | {
35 | "order": [
36 | "static-field",
37 | "instance-field",
38 | "static-method",
39 | "instance-method"
40 | ]
41 | }
42 | ],
43 | "no-arg": true,
44 | "no-bitwise": true,
45 | "no-console": [
46 | true,
47 | "debug",
48 | "info",
49 | "time",
50 | "timeEnd",
51 | "trace"
52 | ],
53 | "no-construct": true,
54 | "no-debugger": true,
55 | "no-duplicate-super": true,
56 | "no-empty": false,
57 | "no-empty-interface": true,
58 | "no-eval": true,
59 | "no-inferrable-types": [
60 | true,
61 | "ignore-params"
62 | ],
63 | "no-misused-new": true,
64 | "no-non-null-assertion": true,
65 | "no-shadowed-variable": true,
66 | "no-string-literal": false,
67 | "no-string-throw": true,
68 | "no-switch-case-fall-through": true,
69 | "no-trailing-whitespace": true,
70 | "no-unnecessary-initializer": true,
71 | "no-unused-expression": true,
72 | "no-use-before-declare": true,
73 | "no-var-keyword": true,
74 | "object-literal-sort-keys": false,
75 | "one-line": [
76 | true,
77 | "check-open-brace",
78 | "check-catch",
79 | "check-else",
80 | "check-whitespace"
81 | ],
82 | "prefer-const": true,
83 | "quotemark": [
84 | true,
85 | "single"
86 | ],
87 | "radix": true,
88 | "semicolon": [
89 | true,
90 | "always"
91 | ],
92 | "triple-equals": [
93 | true,
94 | "allow-null-check"
95 | ],
96 | "typedef-whitespace": [
97 | true,
98 | {
99 | "call-signature": "nospace",
100 | "index-signature": "nospace",
101 | "parameter": "nospace",
102 | "property-declaration": "nospace",
103 | "variable-declaration": "nospace"
104 | }
105 | ],
106 | "typeof-compare": true,
107 | "unified-signatures": true,
108 | "variable-name": false,
109 | "whitespace": [
110 | true,
111 | "check-branch",
112 | "check-decl",
113 | "check-operator",
114 | "check-separator",
115 | "check-type"
116 | ],
117 | "directive-selector": [
118 | true,
119 | "attribute",
120 | "app",
121 | "camelCase"
122 | ],
123 | "component-selector": [
124 | true,
125 | "element",
126 | "app",
127 | "kebab-case"
128 | ],
129 | "use-input-property-decorator": true,
130 | "use-output-property-decorator": true,
131 | "use-host-property-decorator": true,
132 | "no-input-rename": true,
133 | "no-output-rename": true,
134 | "use-life-cycle-interface": true,
135 | "use-pipe-transform-interface": true,
136 | "component-class-suffix": true,
137 | "directive-class-suffix": true,
138 | "invoke-injectable": true
139 | }
140 | }
141 |
--------------------------------------------------------------------------------