由于某种原因,我的 Express 服务器无法正确加载文件系统“fs”模块。我正在使用 Angular-fullstack yeoman 生成器。我的系统是 Windows 7,节点版本为 0.10.35,npm 版本为 2.1.18,以及最新版本的 Angular-fullstack。我尝试了各种方法,例如 32 位和 64 位并更新了所有内容。
routes.js(其中有其他可以正常加载的路由):
'use strict';
var errors = require('./components/errors');
var express = require('express');
var fs = require('fs');
module.exports = function(app) {
app.route('/pdf/*')
.get(function(req, res) {
var pdfPath = app.get('appPath') + '/assets/pdf/test.pdf';
fs.readfile(pdfPath, function(error, data) {
res.setHeader('Content-Disposition', 'attachment; filename="test.pdf"');
res.setHeader('Content-Type', 'application/pdf');
res.setHeader('Content-Length', data.length);
res.status(200).end(data, 'binary');
});
});
// All undefined asset or api routes should return a 404
app.route('/:url(api|auth|components|app|bower_components|assets)/*')
.get(errors[404]);
// All other routes should redirect to …Run Code Online (Sandbox Code Playgroud) 我已经开始在节点js中开发一个新项目了,我使用yeoman的angular fullstack生成器生成了项目.现在我想添加一个新的bower依赖项和一个新的节点依赖项.做这个的最好方式是什么?我应该简单地在bower.json和package.json中添加依赖项,还是应该运行特定的命令?
除了更改密码之外,允许编辑用户文档是不好的做法.我注意到在yo的angular-fullstack上没有更新用户的功能.同样在firebase上,用户注册了身份验证内容,但用户信息(姓名,电话,地址......)需要存储在其他地方.
换句话说,是否有理由让用户文档仅负责身份验证,然后为非身份验证字段提供另一个文档?
我不是在征求意见.只有在同一文档中存储验证字段和非验证字段的事实问题.
尝试在我的AWS EC2 ubuntu服务器上安装这里angular-fullstack中的angular-fullstack框架
运行后出现此错误'gulp serve':
module.js:471 throw err;
Error: Cannot find module './build/bindings/encode.node' at ...
Run Code Online (Sandbox Code Playgroud)
在我的Mac OS上一切正常.我只在我的ubuntu服务器上收到此错误.
救命?请!!!
一些信息:
操作系统:Ubuntu 16.04
我在formgorup中使用angular 5,并希望对控件进行迭代,以便基于表单创建动态组件,表单字段由外部数据服务(数据库等)提供
声明如下
check = new FormGroup({
firstName : new FormControl(true),
lastName : new FormControl(false)
});
Run Code Online (Sandbox Code Playgroud)
我发现这说明了如何迭代控件,但是它不起作用。我尝试使用:
for(let item of this.check.controls){}
Run Code Online (Sandbox Code Playgroud)
并得到这是chrome调试:
无法读取未定义的属性“长度”
我无法访问this.check.controls.keys或keys()
我该如何迭代密钥?
谢谢
我想从我的后端显示一个页面到我的 Angular 前端。
后端:在“ http://localhost:8080/test ”处,我显示一个简单的“hello”文本。
前端:在“ http://localhost:4200/editeur ”处有一个按钮。当我单击按钮时,我想在按钮下显示我的“ http://localhost:8080/test ”内容(在本例中是我的“hello”文本)。
我在 Angular 中使用了 Promise()。
这是我的 Express 后端中间件:
server.use('/test', (req, res, next) => {
res.json({ message: 'Hello' });
console.log('Hello');
next();
});
Run Code Online (Sandbox Code Playgroud)
这是我的 HTML 前端:
<button class="btn btn-success" (click)="getEditeur()">Display backend</button>
Run Code Online (Sandbox Code Playgroud)
这是我的 TS Angular 前端:
getEditeur() {
return new Promise((resolve, reject) => {
this.http.get('http://localhost:8080/test').subscribe(
(response) => {
resolve(response);
},
(error) => {
reject(error);
}
);
});
}
Run Code Online (Sandbox Code Playgroud)
当我单击按钮时,console.log('Hello'); 从我的后端工作来看,前端和后端是紧密相连的。但现在我希望我的 Promise() 在屏幕上显示该res.json({ message: 'Hello' });消息。
谢谢 !
我试图拉取用户的信息并将其设置为我的用户变量,如下所示.我正在使用angular-fullstack样板.
this.getCurrentUser = this.Auth.getCurrentUser;
this.getCurrentUser(function(data){
console.log('data: ', data);
this.username = data.name;
});
Run Code Online (Sandbox Code Playgroud)
但是当这样做时,我得到一个this.username未定义的错误.因此,我的问题是如何将相关信息放入我的变量中.
firebase firebase-hosting angular-fullstack angular angular6
angular ×4
node.js ×3
express ×2
firebase ×2
angular6 ×1
angularjs ×1
asynchronous ×1
formgroups ×1
forms ×1
fs ×1
gulp ×1
javascript ×1
mean-stack ×1
mongodb ×1
promise ×1
ubuntu ×1
web ×1
yeoman ×1
yo ×1