Tag: angularjs

ExpressJS + NodeJS服务器不会提供CSS文件

我试图托pipe我自己的networking服务器,所以我redirect到我的电脑从域的stream量。 交通成功到达我的电脑和网站正在显示,除了ExpressJS不服务唯一的CSS文件,所以我的网站上的内容是因为它没有风格的所有地方。 在控制台中可以看到CSS文件失败的GET: resource: net::ERR_CONNECTION_TIMED_OUT xxx.xx.xx.xxx/styles.176e4d821cc3a21887b2.bundle.css Failed to load 仔细查看错误,我们发现它是唯一失败的文件,即使所有文件与您在下一张图片上看到的都是相同的物理目录: 我正在使用Angular,这是我的dist部署文件夹,你可以看到CSS文件与JS文件位于相同的位置,但只有CSS文件不能被GET'd: 在Express中,我有以下似乎服务于JS和HTML文件,但不是CSS文件: app.use(express.static(path.join(__dirname, '/'))); 此外,一切工作完美的本地主机,它的唯一的stream量redirect从我的.com网站,该网站未能获得的CSS文件。

this.zone.run() – Nzone的错误

我有一个问题,帆+帆sockets + angular4 import { Component, OnInit, NgZone } from '@angular/core'; import { routerTransition } from '../../router.animations'; import { Http } from '@angular/http'; import * as socketIOClient from 'socket.io-client'; import * as sailsIOClient from 'sails.io.js'; @Component({ selector: 'app-tables', templateUrl: './tables.component.html', styleUrls: ['./tables.component.scss'], animations: [routerTransition()] }) export class TablesComponent implements OnInit { io:any; smartTableData:any; constructor(public http: […]

从弹性beanstalk提供静态文件不起作用

我得到了一个angular色的应用程序,从本地主机工作得很好,但在豆茎它没有提供所有我的文件。 只有我的index.html和styles.css被find并提供,都在一个名为public的文件夹中。 我的构build文件是在path/build/build.js,它不会服务它,但在本地主机它会。 我目前只是从我的服务器提供的文件,而不是使用staticfiles.config,因为这是完全不工作。 文件夹结构: root: /public : index.html ,styles.css /src: modularized angular and htmls for routes . /build: build.js const express = require('express'); const path = require('path'); const fs = require('fs'); const bodyParser = require('body-parser'); const emailController = require('./controllers/emailController'); const app = express(); const port = process.env.PORT || 3000; app.use(bodyParser.json()); app.use(express.static(path.resolve(__dirname, '../public'))); app.use(express.static(path.resolve(__dirname, '../'))); […]

在Project Package :: JSHINT中Linting所有JS文件

我正在使用吞咽任务跑步者。 对于静态代码分析,我正在尝试使用JsHint。 这里的问题是我一次只能运行一个文件。 npm安装在package.json中的devDependensies中添加了“gulp-jshint”:“〜1.11.0”。 scripts { "lint" : "jshint <path/file.js>" } 这是非常繁琐的查找项目包中的每个js文件。 我正在寻找方法来绑定我所有的包js文件,并在一个单独的文件中logging他们的报告。

当试图上传一个文件得到404没有find错误节点js

这是我的代码: angular.module('fileModelDirective',[]) .directive('fileModel',['$parse',function ($parse) { return { restrict: 'A', link: function (scope, element, attrs) { var parsedFile = $parse(attrs.fileModel); var parsedFileSetter = parsedFile.assign; element.bind('change', function () { scope.$apply(function () { parsedFileSetter(scope, element[0].files[0]); }); }); } }; }]); 在服务器上我有: app.post('/upload', function (req, res) { upload(req, res, function (err) { if (err) { if (err.code === 'LIMIT_FILE_SIZE') […]

如何处理从POST(NodeJs / Sequelize / Express)收到的数据

我想用express和Sequelize把用户注册到MySQL数据库中。 首先,我应该确保我的客户端(AngularJS)将数据发布到我的routes.js(req.body包含我的数据)文件中: var bodyParser = require('body-parser'); var passport = require('passport'); var session = require('express-session'); module.exports = function (app) { //BodyParser app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); //Passport app.use(session({ secret: 'keyboard cat', resave: true, saveUninitialized: true })); app.use(passport.initialize()); app.use(passport.session()); // persistent login sessions app.post('/registered', function (req, res) { console.log(req.body); res.end(); }); } 接下来,我创build了一个Sequelize用户模型: module.exports = function (sequelize, […]

在Nodejs中查找Mongodb

我正在使用nodejs和MongoDb并使用MongoClient进行连接 我的ejs文件 <form method="POST" action="/addUser"> <div class="modal-content"> <div class="modal-header login-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Add Role</h4> </div> <div class="modal-body"> <input type="hidden" name="_csrf" value=<%=csrfToken%> /> <input type="text" placeholder="Name" name="name" ng-model="name"> <input type="text" placeholder="Password" name="password" ng-model="password"> <select name="role" ng-model="role" > <option ng-repeat="role_type in roles" value="{{role_type._id}}">{{role_type.role}}</option> </select> </div> <div class="modal-footer"> <button type="submit" class="add-project">Save</button> <button type="submit" class="cancel" data-dismiss="modal">Close</button> […]

nodejs mongoDB findOneAndUpdate(); 即使在数据库更新后也会返回true

我正在研究Ionic-1 + nodejs +angular度应用程序。 即使第一次调用更新数据库,我的mongoDb findOneAndUpdate()函数在每次调用时都会返回true。 的NodeJS: app.post('/booking', function (req, res) { var collection = req.db.get('restaurant'); var id = req.body.id; var status = req.body.status; collection.findOneAndUpdate({status: status, id: id},{$set:{status:"booked"}}, function (e, doc) { console.log(id, status); if (e) { console.log(e); } else if(!doc) { res.send(false); } else { res.send(true); } }); }); controller.js $scope.bookMe = function(id){ var […]

在浏览器中加载被X框拒绝

我正在尝试渲染从cloudant下载的pdf文件的URL。 我正在使用angular度和节点来做到这一点。 这是iFrame的html代码 <iframe ng-src="{{trustSrc(bgFileUrl.src)}}" type="application/pdf" width="1400px" height="800px" > </iframe> 在我的节点服务器中,我添加了这些 app.use(function(req, res, next) { res.setHeader("Access-Control-Allow-Methods", "POST, PUT, OPTIONS, DELETE, GET"); res.header("Access-Control-Allow-Origin", "http://127.0.0.1:8000/"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); res.header("Access-Control-Allow-Headers","*"); res.header('Access-Control-Allow-Credentials', true); next(); }); 我的应用程序运行在端口http://127.0.0.1:8000/ 。 我的框架不在mozilla上呈现,并失败,出现以下错误 由X-Frame-Options拒绝加载: https : //myaccount.cloudant.com/不允许通过http://127.0.0.1:8000/file进行加框。 iframe加载在谷歌浏览器,但与此错误。 加载“ https://myaccount.cloudant.com/db/filename/attachment ”时遇到无效的“X-Frame-Options”标头:“ALLOW-FROM https://myaccount.cloudant.com ”不是公认的指令。 标题将被忽略。 有人可以帮我什么添加,以防止这种forms发生。 我是一个初学者在这和帮助表示赞赏

我自己的Trello,将卡片从一个列表移动到另一个列表

首先,我必须说我是一个开始。 我试图创build一个看起来就像Trello的项目,然后我将开始我需要知道,在黑板,列表,卡片(任务)的MongoDB(Mongoose)表中的数据库如何做。 如果我做3个单独的表,我以后如何使用JavaScript拖放移动卡从上到下列表中和我想要的步骤列表之间。 我的意思是,我如何做到这一点,当我把卡从一个列表中移动到另一个卡中,它将更新所有内容并将其保存在数据库中。 我想有人解释我该怎么做,我将非常感激。