Reputation: 1532
My app in angular2 was fully functional loading component after component. When I tried to use it with electron everything went downhill. I keep trying to follow different tutorials, but they are not working for me. Can anyone point me in the direction on why this is not working please.
index.html inside app/
<html>
<head>
<meta charset="utf-8">
<title>QuizzUmmah</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<h1>Index On</h1>
<app></app>
<script src="../node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="../build/common.js"></script>
<script src="../build/angular2.js"></script>
<script src="../build/app.js"></script>
</body>
</html>
App.ts inside app/start/
///<reference path="../../node_modules/angular2/typings/browser.d.ts"/>
import {bootstrap} from "angular2/platform/browser";
import { Component, provide } from "angular2/core";
import { ROUTER_DIRECTIVES, RouteConfig, Router, ROUTER_PROVIDERS } from 'angular2/router';
import { APP_BASE_HREF,HashLocationStrategy, Location, LocationStrategy } from '@angular/common';
import { Control } from 'angular2/common';
import { HomeComponent } from '../home/home.component';
@RouteConfig([
{ path: '/home', component: HomeComponent, name: 'HomeComponent' },
{ path: '/**', redirectTo: ['HomeComponent'] }
])
@Component({
selector: "app",
template:`<h1>Working</h1>
<router-outlet></router-outlet>`,
directives: [ROUTER_DIRECTIVES],
})
export class App {}
bootstrap(App, [
ROUTER_PROVIDERS,
provide(APP_BASE_HREF, { useValue: '/' }),
provide(LocationStrategy, { useClass: HashLocationStrategy })
]);
HomeComponent inside app/home
import { Component} from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-home',
template: `<h1>Home is working</h1>`,
})
export class HomeComponent{
constructor(){}
}
Upvotes: 1
Views: 2496
Reputation: 2335
Just change the body of the index.html file like below. Use a <base>
tag inside the body without the "/" symbol and try it.
<body>
<base href="">
<h1>Index On</h1>
<app></app>
<script src=".....></script>
</body>
Upvotes: 1