Add routing module
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "angular-electron",
|
"name": "angular-electron",
|
||||||
"version": "1.3.0",
|
"version": "1.3.",
|
||||||
"description": "Angular 4 with Electron (Typescript + SASS + Hot Reload)",
|
"description": "Angular 4 with Electron (Typescript + SASS + Hot Reload)",
|
||||||
"homepage": "https://github.com/maximegris/angular-electron",
|
"homepage": "https://github.com/maximegris/angular-electron",
|
||||||
"author": {
|
"author": {
|
||||||
@@ -17,14 +17,14 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
|
"lint": "ng lint",
|
||||||
"start": "webpack --watch",
|
"start": "webpack --watch",
|
||||||
"test": "karma start ./karma.conf.js",
|
"test": "karma start ./karma.conf.js",
|
||||||
"lint": "ng lint",
|
|
||||||
"e2e": "protractor ./protractor.conf.js",
|
"e2e": "protractor ./protractor.conf.js",
|
||||||
"build": "webpack --display-error-details && copyfiles main.js dist",
|
|
||||||
"build:prod": "cross-env NODE_ENV='production' npm run build",
|
|
||||||
"prepree2e": "npm start",
|
"prepree2e": "npm start",
|
||||||
"pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
|
"pree2e": "webdriver-manager update --standalone false --gecko false --quiet",
|
||||||
|
"build": "webpack --display-error-details && copyfiles main.js dist",
|
||||||
|
"build:prod": "cross-env NODE_ENV='production' npm run build",
|
||||||
"electron:serve": "electron . --serve",
|
"electron:serve": "electron . --serve",
|
||||||
"electron:dev": "npm run build && electron dist/main.js",
|
"electron:dev": "npm run build && electron dist/main.js",
|
||||||
"electron:prod": "npm run build:prod && electron dist/main.js",
|
"electron:prod": "npm run build:prod && electron dist/main.js",
|
||||||
|
|||||||
16
src/app/app-routing.module.ts
Normal file
16
src/app/app-routing.module.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { HomeComponent } from './home/home.component';
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: HomeComponent
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forRoot(routes)],
|
||||||
|
exports: [RouterModule]
|
||||||
|
})
|
||||||
|
export class AppRoutingModule { }
|
||||||
@@ -1,4 +1 @@
|
|||||||
<h1 class="title">
|
<router-outlet></router-outlet>
|
||||||
{{title}}
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
.title {
|
|
||||||
color: black;
|
|
||||||
margin:0;
|
|
||||||
padding:50px 20px;
|
|
||||||
background: url(../assets/background.jpg) no-repeat center fixed;
|
|
||||||
-webkit-background-size: cover; /* pour anciens Chrome et Safari */
|
|
||||||
background-size: cover; /* version standardisée */
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,17 +16,4 @@ describe('AppComponent', () => {
|
|||||||
const app = fixture.debugElement.componentInstance;
|
const app = fixture.debugElement.componentInstance;
|
||||||
expect(app).toBeTruthy();
|
expect(app).toBeTruthy();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it(`should have as title 'app works!'`, async(() => {
|
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
|
||||||
const app = fixture.debugElement.componentInstance;
|
|
||||||
expect(app.title).toEqual('app works!');
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should render title in a h1 tag', async(() => {
|
|
||||||
const fixture = TestBed.createComponent(AppComponent);
|
|
||||||
fixture.detectChanges();
|
|
||||||
const compiled = fixture.debugElement.nativeElement;
|
|
||||||
expect(compiled.querySelector('h1').textContent).toContain('app works!');
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,13 +8,10 @@ import * as childProcess from 'child_process';
|
|||||||
styleUrls: ['./app.component.scss']
|
styleUrls: ['./app.component.scss']
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
title = `App works !`;
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
// Check if electron is correctly injected (see externals in webpack.config.js)
|
// Check if electron is correctly injected (see externals in webpack.config.js)
|
||||||
console.log('c', ipcRenderer);
|
console.log('c', ipcRenderer);
|
||||||
// Check if nodeJs childProcess is correctly injected (see externals in webpack.config.js)
|
// Check if nodeJs childProcess is correctly injected (see externals in webpack.config.js)
|
||||||
console.log('c', childProcess);
|
console.log('c', childProcess);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,20 @@ import { FormsModule } from '@angular/forms';
|
|||||||
import { HttpModule } from '@angular/http';
|
import { HttpModule } from '@angular/http';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
|
import { HomeComponent } from './home/home.component';
|
||||||
|
|
||||||
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent
|
AppComponent,
|
||||||
|
HomeComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
HttpModule
|
HttpModule,
|
||||||
|
AppRoutingModule
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
|
|||||||
3
src/app/home/home.component.html
Normal file
3
src/app/home/home.component.html
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<h1 class="title">
|
||||||
|
{{title}}
|
||||||
|
</h1>
|
||||||
8
src/app/home/home.component.scss
Normal file
8
src/app/home/home.component.scss
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
.title {
|
||||||
|
color: black;
|
||||||
|
margin:0;
|
||||||
|
padding:50px 20px;
|
||||||
|
background: url(../../assets/background.jpg) no-repeat center fixed;
|
||||||
|
-webkit-background-size: cover; /* pour anciens Chrome et Safari */
|
||||||
|
background-size: cover; /* version standardisée */
|
||||||
|
}
|
||||||
38
src/app/home/home.component.spec.ts
Normal file
38
src/app/home/home.component.spec.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { HomeComponent } from './home.component';
|
||||||
|
|
||||||
|
describe('HomeComponent', () => {
|
||||||
|
let component: HomeComponent;
|
||||||
|
let fixture: ComponentFixture<HomeComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ HomeComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(HomeComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should have as title 'App works !'`, async(() => {
|
||||||
|
const fixture = TestBed.createComponent(HomeComponent);
|
||||||
|
const app = fixture.debugElement.componentInstance;
|
||||||
|
expect(app.title).toEqual('aApp works !');
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should render title in a h1 tag', async(() => {
|
||||||
|
const fixture = TestBed.createComponent(HomeComponent);
|
||||||
|
fixture.detectChanges();
|
||||||
|
const compiled = fixture.debugElement.nativeElement;
|
||||||
|
expect(compiled.querySelector('h1').textContent).toContain('App works !');
|
||||||
|
}));
|
||||||
|
});
|
||||||
16
src/app/home/home.component.ts
Normal file
16
src/app/home/home.component.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-home',
|
||||||
|
templateUrl: './home.component.html',
|
||||||
|
styleUrls: ['./home.component.scss']
|
||||||
|
})
|
||||||
|
export class HomeComponent implements OnInit {
|
||||||
|
title = `App works !`;
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user