我有一个角度2项目,可以继续加载。我是从喷泉发电机为自耕农生成的。
HTML
<h1>{{ hello }}</h1>
组件
var ng = require('@angular/core');
module.exports = ng.Component({
selector: 'fountain-app',
template: require('./hello.html')
})
.Class({
constructor: function () {
this.hello = 'Hello World!';
}
});
模块
var ng = require('@angular/core');
var ngPlatformBrowser = require('@angular/platform-browser');
var myRoutes = require('./routes');
var HelloComponent = require('./hello');
module.exports = ng.NgModule({
imports: [
ngPlatformBrowser.BrowserModule,
myRoutes.routing
],
declarations: [
myRoutes.RootComponent,
HelloComponent
],
bootstrap: [myRoutes.RootComponent]
})
.Class({
constructor: function () {}
});
路由器
var ng = require('@angular/core');
var ngRouter = require('@angular/router');
var HelloComponent = require('./hello');
var RootComponent =
ng.Component({
selector: 'fountain-root',
template: '<router-outlet></router-outlet>'
})
.Class({
constructor: function () {}
});
var routes = [
{
path: '',
component: HelloComponent
}
];
module.exports = {RootComponent: RootComponent, routes: routes, routing: ngRouter.RouterModule.forRoot(routes)};
的index.html
<!doctype html>
<html>
<head>
<base href="/">
<meta charset="utf-8">
<title>FountainJS</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="icon" type="image/png" href="http://fountainjs.io/assets/imgs/fountain.png" />
</head>
<body>
<fountain-root>Loading...</fountain-root>
</body>
</html>
自举
require('core-js/client/shim');
require('zone.js/dist/zone');
require('@angular/common');
require('rxjs');
require('./index.scss');
var ngCore = require('@angular/core');
var ngPbd = require('@angular/platform-browser-dynamic');
var AppModule = require('./app');
if (process.env.NODE_ENV === 'production') {
ngCore.enableProdMode();
} else {
Error['stackTraceLimit'] = Infinity; // eslint-disable-line dot-notation
require('zone.js/dist/long-stack-trace-zone');
}
ngPbd.platformBrowserDynamic().bootstrapModule(AppModule);
我使用golang作为后端但是没有必要发布代码,因为它正在加载angular index.html。我检查了404错误,但没有。
有什么想法吗?