Tag: angularjs

AngularJS中的IIS URL重写与angular度HTML5模式的节点

我有一个构build在Azure(IIS)托pipe的Node.JS之上的AngularJS应用程序,并使用HTML5模式。 在我不使用Node.JS的情况下,只使用AngularJS和IIS,我可以重写URL,以便在IIS Web.config中使用以下规则刷新页面不会导致404错误: <rule name="AngularJSHTML5Mode" stopProcessing="true"> <match url=".*"/> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> <add input="{REQUEST_URI}" pattern="^/(api)" negate="true"/> </conditions> <action type="Rewrite" url="/"/> </rule> 但是,在Node.js(使用ExpressJS)上使用Angular时,即使在IIS中使用上述规则,也会在页面刷新时收到“Can not GET / myroute”等错误。 有什么我需要在Server.js或Web.config中configuration不同的规则。 这是我目前在Express中的内容。 我正在使用Express 4: // Initialize Express App var app = express(); var listener = app.listen(1337, function () { console.log('Listening on port ' […]

来自Express / Node.js的HTTP请求

我正在尝试为一个程序设置一个快速服务,我正在写这个联系人的一个外部API,然后返回结果,以便它可以存储在我设置的Mongo中。 这似乎应该是相当简单的,但我是新的Node.js / Express,我得到一个“发送后无法设置标头”错误。 我从外部API获取我想要的数据,但是如何正确地将数据发送回我的A​​ngular app.js,以便在我的表中更新? “addSelected()”是我在app.js中调用的函数,用于启动进程。 “数据”打印完整响应的一部分,然后切断,并给我“发送后无法设置标题”错误。 从我理解这是从发送的响应,然后试图修改响应头后的事实..但我不确定的解决方法,或者如果我只是格式化一切错了,因为这是我第一次摆动MEAN堆栈一般。 我知道问题是在server.js中的“res.send(data)”行,但我不知道如何正确地格式化响应。 我的代码: server.js //server.js //setup ============================== var express = require ('express'); var request = require('request'); var app = express(); var mongoose = require('mongoose'); var https = require('https'); //config ============================ app.use(express.static(__dirname + '/public/')); console.log("running PipeHelper"); mongoose.connect('mongoedit'); var Schema = mongoose.Schema; var opSchema = new Schema({ title: String, […]

在构buildangularjs包之后,如何将nodejs作为后端请求服务器来部署angularjs

在构buildangularjs包之后,如何将nodejs作为后端请求服务器来部署angularjs 我的项目结构:app / app / config app / scripts app / styles app / views bower_components / dist / node_modules / test / server.js 使用grunt构buildangular度包后,我只使用dist文件夹。 但我想用我的请求节点,服务器。 那么如何在dist build文件夹中设置nodejs包。 这将被部署到parse.com

如何在Express中启用HTML5模式而不破坏NodeMailer?

大家。 我正在制作我的第一个Node + Express + Angular应用程序。 我有点用https://github.com/codeschool/StayingSharpWithAngularSTB作为锅炉板。 总体布局是 [文件夹]应用程序 ——— [子文件夹]资产(Javascript,CSS,图像等) ——— [子文件夹]页面(这包含ng视图的东西) ——— [子文件夹]视图 ——————– index.html(这是主要的index.html,它把所有东西放在一起) [文件夹] node_modules [文件夹]服务器 ——— [子文件夹]控制器 ———————- core.server.controller.js ——— expressConfig.js ——— routes.js app.js 的package.json 所以这里是我的服务器configuration文件: app.js var app = require("./server/routes"); // Start the server var port = process.env.PORT || 8000; app.listen(port, function(){ console.log('Listening on port ' + port); }); […]

bower安装是否需要与bower.json运行在同一个文件夹中?

我使用快递生成器https://github.com/expressjs/generator,并混合angular种子项目https://github.com/angular/angular-seed到它创build一个平均堆栈应用程序的轻量级脚手架。 我想能够运行npm start来安装包括前端的所有依赖项。 问题是angular度/前端相关的文件不在根目录中,而是在“公共”子目录中。 我知道我可以创build一个运行bower install的npm start脚本,但是我不知道如何让启动脚本进入公共子目录,然后运行bower install 。 我的问题是bower install试图在子目录中查找bower.json文件,还是在工作目录中查找bower.json文件后停止search? 如果前者,那么我可以运行bower install而不必担心手动导航文件夹结构。 如果bower install不会在子目录中searchbower.json,那么我怎样才能将这个命令作为npm start脚本的一部分? 这似乎命令将不得不改变目录到“公共”子目录,然后运行bower install 。 最后,这对我来说主要是一个部署问题。 我使用的是部署时自动运行npm install和启动脚本的heroku,当它检测到package.json文件的存在。 所以,我似乎需要包括包括bower install作为启动脚本的一部分。

AngularJS – 如何使用Http Web服务器呈现视图时禁用目录浏览/列表

我的RESTful MEAN应用程序在后端有一个node.js服务器,在前端有一个HTTP服务器。 以下是项目结构: 当我从控制台运行我的目录/应用程序/ HTTP服务器,并执行浏览其显示页面,如下所示的目录列表/浏览: 一旦我点击浏览页面正在渲染。 以下是我的app.js: 'use strict'; var app = angular.module('app', ['ngRoute', 'authControllers', 'authServices']); var authControllers = angular.module('authControllers', []); var authServices = angular.module('authServices', []); var options = {}; options.api = {}; //dev URL options.api.base_url = "http://localhost:3000"; app.config(['$locationProvider', '$routeProvider', function($location, $routeProvider) { $routeProvider. when('/', { templateUrl: 'partials/home.html', controller: 'authCtrl' }). when('/login', { templateUrl: 'partials/signin.html', […]

如何使用Express,AngularJS,Socket.io广播和获取通知?

我正在尝试通知系统。 为了演示这一点,用户1正在向用户2发送好友请求。我正在使用express.js,angularjs和socket.io。 点击buttonUser1发送请求。 在User2的最后,有一个socket,on()正在监听好友请求事件。 但是当我广播时,另一个用户不能接收任何消息。 app.js (节点服务器文件) var express = require('express'), app = express(); var port = process.env.PORT || 3000; var io = require('socket.io').listen(app.listen(port)); require('./config')(app,io); require('./routes')(app,io); config.js // This file handles the configuration of the app. // It is required by app.js var express = require('express'); module.exports = function(app, io){ // Set .html as the […]

在Heroku上部署Angul应用程序:应用程序崩溃

我有一个使用Gulp的Node.js + Angular web应用程序。 当我运行命令“gulp serve”时,它在我的本地机器上完美地工作。 我正在尝试在Heroku中部署它,并在网上find了一些资源,所以我做了以下工作。 我用这个内容在根目录中创build了一个名为web.js的新文件: var gzippo = require('gzippo'); var express = require('express'); var app = express(); app.use(express.logger('dev')); app.use(gzippo.staticGzip("" + __dirname + "/build")); app.listen(process.env.PORT || 5000); 我用这个内容在根目录中创build了一个名为Procfile的新文件: web: node web.js 这是package.json文件。 请注意,我已经添加了gulp serve作为启动脚本和bower install作为postinstall,因为它是在本地工作的方式。 { "name": "myapp", "version": "0.0.1", "dependencies": { "express": "^4.13.3", "bower": "1.6.5", "gzippo": "^0.2.0", }, "scripts": { "test": "gulp […]

Ag-grid不能和angular和webpack一起工作

我正在试图让ag-grid与webpack一起工作。 我已经完成了标准的事情,通过添加通过npm的网格,并添加了引用webpack.config这样做: resolve: { alias: {"ag-grid" : path.resolve(__dirname, "./node_modules/ag-grid/dist/ag-grid.js") } 该文件得到解决,并加载到索引文件就好了。 我做了以下的angular度。 angular.module("cs-app", [require("ag-grid").name]); Webpack也parsing这个文件,并被包含并加载,但是当我运行应用程序,我得到以下错误。 [$injector:modulerr] Failed to instantiate module angularGridGlobalFunction due to: [$injector:nomod] Module 'angularGridGlobalFunction' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. 我无法在ag-grid.js中find名称angularGridGlobalFunction,但是当我注释掉对ag-grid的引用时,该应用程序工作得很好。 […]

发布请求不会与Angular.js一起发送。 我究竟做错了什么?

所以即时通讯尝试从客户端点击一个名称,并发送名称(我改变为json为了实际上能够发送信息)到服务器。 现在,服务器发送回来,客户端将其发布到索引页面(即时通讯,以便我可以看到服务器正在获取的数据)。 当我看到数据显示为[对象对象]。 所以有些事情出错了,我希望有人能帮助我。 的index.html <body> <div ng-app="myApp" ng-controller="customersCtrl"> <table style="width:100%"> <tr ng-repeat="contact in databases.databases"> <td>{{ contact.name }} <button type="button"ng-click="addContactlist(contact.name)">Click Me</button></td> <td>{{ contact.sizeOnDisk }} </td> <td>{{ contact.empty }} </td> </tr> </table> DB name clicked: <p ng-bind="DB_NAME"></p> </div> </body> client.js var app = angular.module('myApp', []); app.controller('customersCtrl', function($scope, $http) { console.log("controller connected"); function refresh(){ // create contacklist […]