Tag: angularjs

当我使用AngularJS和Node.JS上传文件时,“NetworkError:404 Not Found”

我想要上传文件时遇到此错误: “NetworkError:404 Not Found – http://127.0.0.1:8080/src/img ” 404:找不到 这是我的页面视图的代码: <div class="col-sm-10"> <input type="file" ngf-select="uploadFiles($file)" accept="image/*" ngf-max-height="1000" ngf-max-size="1MB"> </div> 我正在使用ngFileUpload模块 我的控制器: $scope.uploadFiles = function(file){ if (file) { file.upload = Upload.upload({ url: 'img', data: {file: file} }); file.upload.then(function (response) { $timeout(function () { console.log(response.data); }); }, function (response) { if (response.status > 0) console.log(response.status + ': ' […]

如何删除amazon s3文件w / nodejs /angular

var awsSdk = require('aws-sdk'); awsSdk.config = { "accessKeyId": "key", "secretAccessKey": "secret", "region": "us-east-1" } var s3 = new awsSdk.S3({ accessKeyId: 'key', secretAcessKey: 'secret' }); exports.awsDelete = function(req, res){ s3.deleteObject({ Bucket: 'bucket', Key: req.body.photo }, function(err,data){ if (err) console.log('delete err', err); console.log(data); }); }; 我无法弄清楚如何使这项工作(还)。 最初,我得到了一个“无configuration”的错误,所以我添加了上面的awsSdk.config json。 现在,它只是挂起/暂停没有错误。 我正在req.body.photo中获得预期的关键。 我的直觉是,我在我的configuration丢失的东西.. 我在想什么/搞砸了? 更新我已经添加了下面的代码,但仍然没有运气。 我将显示如何传递我的参数: 从下面的答案更新代码: 'use strict'; […]

宣布2个控制器在一个页面中使用

我有2个控制器,我想要使用。 其中之一是ModalDemoCtrl和另一个是ReportController。 我如何声明两个控制器共享相同的状态,url和templateUrl? app.js angular .module('app', [ 'ui.router', 'lbServices', 'ngAnimate', 'ui.bootstrap' ]) .config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { $stateProvider .state('report', { url: '/report', templateUrl: 'views/report.html', controller: 'ModalDemoCtrl', authenticate: true }) .state('report', { url: '/report', templateUrl: 'views/report.html', controller: 'ReportController', authenticate: true });

如何将文件从节点jsstream式传输到angular度js

我是新angular度和节点js。 我正在尝试从节点发送文件内容到angular度。 但是我不能从我的angular码中读取它 这是我的代码 节点快递 var img = fs.readFileSync('./test.jpg'); //res.writeHead(200, {'Content-Type': 'image/jpg' }); //res.end(img, 'binary'); res.send({'data':img}); console.log(img); angular码是 <img ng-src="data:image/JPEG;base64,{{image}}">

Angular2种子:npm开始有吞咽错误

当我在angular2种子文件上运行npm start时,我尝试着试着给它发回一个错误,说它在gulp脚本中失败了。 我的节点和npm是最新的,所以不能这样。 有没有其他人有这个错误或有什么build议可能是什么? angular种子文件: https : //github.com/mgechev/angular2-seed我的节点版本:v6.2.1我的NPM版本:3.10.1 charlottes-mbp:angular2-seed 2 charlotte$ npm start > angular2-seed@1.0.0 start /Users/charlotte/angular2-seed 2 > concurrent "npm run gulp" "npm run lite" "concurrent" command is deprecated, use "concurrently" instead. [0] [0] > angular2-seed@1.0.0 gulp /Users/charlotte/angular2-seed 2 [0] > gulp [0] [1] [1] > angular2-seed@1.0.0 lite /Users/charlotte/angular2-seed 2 [1] > lite-server [1] […]

AngularJS + ServiceStack + Node.js作为代理?

我已经在angularjs中创build了一个应用程序。 服务器端由服务栈覆盖,我想处理由服务栈应用程序提供的json文件。 要做到这一点,我使用angularjs中的以下代码: taskListApp.factory('Fact', function ($resource) { return $resource("http://localhost:55267/hello?format=json", {}, { query: {method: 'GET', url: "http://localhost:55267/hello?format=json"}, }); }); 然而,我得到的错误在控制台中的相同的原点策略,缺lessCORS头。 我试图使用默认的node.js模板来创build一个proxxy服务器,但是我对我应该使用哪个端口毫无头绪。 任何标题? 编辑:这是我的node.js代码,它返回未处理的“错误”错误 httpProxy.createServer({ target:'http://localhost:55267' }).listen(8003); http.createServer(function (req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2)); res.end(); }).listen(55267);

无法加载Java脚本文件和bower_components / angular / angular.js

当我运行localhost:3000服务器,我在控制台中得到这些错误: http:// localhost:3000 / bower_components / angular / angular.js加载资源失败:服务器响应状态为404(未find) http:// localhost:3000 / controller.js加载资源失败:服务器响应状态为404(未find) 这是工作,如果我把angular.js脚本在index.html而不是把它分开在controller.js,我不知道为什么我得到一个错误,当我使用脚本标记。 目录图是这样的 -files -bower_components -angular -index.html -controller.js -server.js 这是index.html文件 <!DOCTYPE html> <html ng-app="App"> <head> <style> #list { margin-left:320px; font-size: 40px; font-family:verdana; } button { color:yellow;background-color:red;text-align:center;cursor:pointer; -webkit-transition-duration: 0.4s; transition-duration: 0.4s; font-size:40px; padding: 14px 32px; } button:hover { background-color:peachpuff; color:tomato; } </style> </head> <body […]

如何从本地主机中的node.js restful api获取angular.js文件的数据

我为rest api创build了main.js。当我从vericek.js发送请求到本地服务器时,响应没有回来,但localserver显示在terminal发送数据。 问题是什么。 谢谢 的index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <title></title> <link href="lib/ionic/css/ionic.css" rel="stylesheet"> <link href="css/style.css" rel="stylesheet"> <!– IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above <link href="css/ionic.app.css" rel="stylesheet"> –> <!– ionic/angularjs js –> <script src="lib/ionic/js/ionic.bundle.js"></script> <!– cordova script (this […]

如何包含明确键入Angular 2项目中的文件

我正在一个angular2 / node.js应用程序,我目前正在尝试安装types的项目。 以前,当我将运行服务器,并启动typscript compilerm我会得到以下日志: bash-3.1$ npm start > support-dashboard@1.0.0 start c:\MEAN_project > concurrently "npm run tsc:w" "node server.js" [1] Magic happens on port 8080 [0] [0] > support-dashboard@1.0.0 tsc:wc:\MEAN_project [0] > tsc -w [0] [0] node_modules/angular2/platform/browser.d.ts(78,90): error TS2304: Cannot find name 'Promise'. [0] node_modules/angular2/src/core/application_ref.d.ts(38,88): error TS2304: Cannot find name 'Promise'. [0] node_modules/angular2/src/core/application_ref.d.ts(92,42): error TS2304: […]

错误:ENOENT:没有这样的文件或目录与Angular2和Express.js

我正在对GitHub上的这个示例Angular2应用程序进行小的修改,以便它使用Express.js而不是KOA。 但目前,当我尝试在FireFox中加载应用程序时, nodemon控制台中会显示以下错误: Error: ENOENT: no such file or directory 当localhost : 8080的http请求触发*路由器处理程序时,Angular2应用程序开始加载,该处理程序返回index.html ,然后触发一系列嵌套依赖项的callback,其中一个引发错误并暂停应用程序加载mid-通过方式。 需要对GitHub示例中的代码进行哪些特定的更改才能解决Error: ENOENT: no such file or directory ? 背景和代码: 这里是使用Express.js代替KOA的router.js的新替代品: 'use strict'; let uuid = require('node-uuid'); var path = require('path'); let jwt = require('jsonwebtoken'); let config = require('./config'); // expose the routes to our app with module.exports module.exports = function(app) { […]