【发布时间】:2018-01-01 22:25:26
【问题描述】:
我正在使用 Angular2 创建一个动态网站,但在向其中添加引导程序时遇到了严重的麻烦。
我的 index.html 文件如下所示:
<!DOCTYPE html>
<html>
<head>
<script>
document.write('<base href="' + document.location + '" />');
</script>
<title>Angular.io QuickStart</title>
<base href="/">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="/">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('app/main.js').catch(function(err) {
console.error(err);
});
</script>
</head>
<body>
<my-app>Loading App</my-app>
</body>
</html>
然后我尝试将它导入到我的 app.module.ts 文件中,如下所示:
import { NgModule } from 'angular2/core';
import { BrowserModule } from '@angular2/platform-browser';
import { Alert } from 'ng2-bootstrap/ng2-bootstrap';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
特别是这些行给出了“找不到模块”错误:
import { NgModule } from 'angular2/core';
import { BrowserModule } from '@angular2/platform-browser';
import { Alert } from 'ng2-bootstrap/ng2-bootstrap';
我正在运行从 nuGet 包管理器安装的 Angular2 + ASP.net 模板。我还从包管理器控制台安装了 ng2-bootstrap 和 ng-bootstrap 版本。我还更新了我的 node.js 包和我的 angular 文件。
我对 Angular 整体来说是全新的,只是想建立我的基础,这样我就可以开始使用这些功能了。
那么我当前的解决方案有什么问题,我可以做些什么来解决它?有没有更简单/更好的方法将引导程序绑定到我的 Angular2 应用程序?
【问题讨论】:
-
考虑改用 angular-cli,它由与 angular 团队密切联系的 google 团队保持最新:github.com/angular/angular-cli
-
你在使用 angularcli 吗?
-
'特别是这些行有错误' - 你应该提到错误是什么。
-
@JoeClay 已编辑,谢谢。
-
@EduardoVargas 我刚刚了解了 mage 到 angular 的命名更改,我将立即查看 CLI
标签: javascript css twitter-bootstrap angular