如何在Express.js中将Angular 2应用添加为视图
How to add an Angular 2 App as a view in Express.js
我正在用Angular 2制作一个应用程序,需要从服务器上运行的脚本中获取数据。为了做到这一点,我试图将我已经存在的Angular应用程序作为视图添加到express应用程序中,就像这里所做的那样。我遵循了教程中概述的文件夹结构的初始设置说明,但教程并没有介绍如何实际连接Angular和express应用,以便在使用npm start
时它们能一起运行。
然后我发现了另一个帖子,建议使用express/angular生成器,我最终安装了它,产生了这个包。json文件:
{
"name": "support-dashboard",
"version": "0.0.0",
"dependencies": {
"express": "~3.0.0",
"ejs": "~0.8.4"
},
"devDependencies": {
"connect-livereload": "~0.2.0",
"grunt": "~0.4.1",
"grunt-concurrent": "~0.3.0",
"grunt-contrib-clean": "~0.4.1",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-compass": "~0.3.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-connect": "~0.3.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-imagemin": "~0.1.4",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-watch": "~0.4.0",
"grunt-google-cdn": "~0.2.0",
"grunt-karma": "~0.4.3",
"grunt-ngmin": "~0.0.2",
"grunt-open": "~0.2.0",
"grunt-rev": "~0.1.0",
"grunt-svgmin": "~0.2.0",
"grunt-usemin": "~0.1.11",
"jasmine-core": "^2.4.1",
"karma": "^1.1.2",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.1",
"matchdep": "~0.1.2",
"phantomjs-prebuilt": "^2.1.11"
},
"engines": {
"node": ">=0.8.0"
},
"scripts": {
"test": "karma start test''karma.conf.js"
}
}
尽管这个包打算在Express之上提供Angular的设置,但这个文件只是为Express而不是Angular设置的。在Express中建立Angular 2项目的官方方式是什么?
我打赌官方的方法是使用角通用。允许您减轻搜索引擎优化问题与一页应用程序。https://universal.angular.io/
相关文章:
- 如何添加CSS&JavaScript进入Windows窗体应用程序C#.net
- 当我在重新启动cordova应用程序后尝试添加更多数据时,lokijs会丢失数据库和收集中的数据
- Jquery添加一个类之后,如何应用css
- 将Rails后端添加到JS/HTML/CSS应用程序时,正确的文件位置是什么
- 通过JS添加类时应用CSS转换
- 如何使用JavaScript's”;应用“;方法,在数组之前添加一个额外的参数
- 将Google Adwords脚本添加到Vaadin应用程序中
- 将jquery函数动态应用于添加的元素
- 只需添加一个'允许跨来源请求'到我的节点应用程序工作
- 将admob广告添加到phonegap应用程序
- 将文本工具添加到绘制应用程序HTML5画布
- 无法将日期选取器应用于使用 .load 添加到应用程序的 html 页面上的字段
- 如何将JS应用于用户在表格中添加的行
- Ruby on Rails 4:在 Rails Web 应用程序中添加 Javascript 文件时遇到问题
- 如何在 Rails 应用程序中向 Galleria 添加自定义描述
- 如何使用Bootstrap和Heroku为Rails应用程序添加隐藏的播放音频
- 根据角度 js 应用程序中的条件动态添加类
- 如何在滚动时将jQuery fadeIn添加到Angular应用程序中
- 给这个快递应用添加一个错误页面
- 如何在Express.js中将Angular 2应用添加为视图