Tag: angularjs

如何在angularjs中加载一个文本域

我正在开发一个应用程序,我想要加载一个文本字段在窗体中被禁用编​​辑。 我想要两件事情得到回答。 其实我的想法是从url中获取一个mongodb _id ,并将其传递给我的控制器,并从数据库获取相应的电子邮件ID,并在加载表单中填写,以便用户不能在该字段中编辑它。 问题1:我已经写了使用ID获取电子邮件ID的API,但我不知道如何从我的url获取_id 。 说www.xyzabc.com/register.html?id:57c5dda12e63d15d2e4dea2c www.xyzabc.com/register.html?57c5dda12e63d15d2e4dea2c 任何格式的url。 我的API是这样的: $scope.fetchEmail = function (id) { $scope.id = "57c5dda12e63d15d2e4dea2c"; console.log("logging routeparam"); console.log($scope.id); UserServices.fetchEmail($scope.id, function (email) { console.log("insied fetch fn"); console.log(email); $scope.user.email = email; }); } 如果ID是硬编码的,上面的代码会做一切完美的事情。 我不知道如何从url获取url参数作为id。 问题2:一旦我在$scope.user.email = email;获得我的id, 它应该被填充在禁止用户编辑的字段中。 我尝试了下面的代码,但它不适合我。 <input name="email" id="email" class="form-control" placeholder="Email" ng-model={{"user.email"}} disabled="disabled" required> 任何人都可以帮我解决这个问题。提前感谢。

使用Express和Mulder无法访问上载文件夹中的图像

我有一个build立在Node / Express / Angular上的应用程序。 我有我所有的angular度前端代码在一个“客户端”的文件夹,我有我的所有后端(nodejs和expression)在另一个文件夹(“服务器”)。 我使用Grunt将代码编译到“server / dist”文件夹中,所以当我发布到生产环境时,我只是上传“server”文件夹。 我已经添加了一个function来上传图片,并使用multer来做到这一点。 我在“服务器”目录中创build了一个“fileuploads”文件夹,并成功地将file upload到该文件夹​​。 问题: 在我的应用程序中,我需要引用图像,但即使我已经在我的服务器/ app.js文件中创build了一个静态引用,但仍无法find它们。 这是我的服务器端app.js文件的样子: var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var mongoose = require('mongoose'); var cors = require('cors'); var multer = require('multer'); mongoose.connect('mongodb://localhost/OM'); var app […]

angular-cli没有安装在ubtunu 16.04

我已经多次尝试在我的Ubuntu 16.04上安装angular-cli,但每次失败。 我正在使用节点版本6.9.1和npm版本3.10.8。 我在这篇文章中附上错误。 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/angular-cli/node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.14: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/compiler@2.0.2 but none was installed. npm WARN @angular/compiler-cli@0.6.4 requires a peer of @angular/platform-server@2.0.2 but none was installed. npm WARN @angular/compiler-cli@0.6.4 requires a […]

节点js如何使用“node_modules”库而不是“src = <cdn>”

我知道这是一个反复出现的问题,但我没有看到我完全理解的答案。 我正在使用我的节点js应用程序,在我的index.html一些cdn地址。 即: <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.min.js"></script> 但我也有这个文件夹在我的node_modules目录..所以我真的不需要使用CDN。 我只能使用我的node_modules目录中的文件。 问题是如何? 现在我有这个: app.use(express.static(path.join(__dirname, '/'))); 在我的server.js文件中。 但这不是我的节点mudles文件夹(这是在我的index.html相同的根path下)的path。 我试图写一些像: app.use('/scripts', express.static(__dirname + '/node_modules/')); 并在我的index.html中写下如下内容: <script src="scripts/angular-ui-router/angular-ui-router.min.js"></script> 但是当我到localhost时,应用程序甚至没有启动:3000因为我得到这个错误: Error: ENOENT, stat …… at Error (native) 我的问题是:1.我需要写在我的server.js而不是app.use(express.static(path.join(__dirname, '/'))); 2.我需要写在我的index.html文件中,而不是: <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.1/angular-ui-router.min.js"></script> 这是我刚刚添加时收到的消息: app.use('/scripts', express.static(path.join(__dirname, 'node_modules'))); 错误: Error: ENOENT, stat 'C:\<path_to_my_project>\server_modules\index.html' at Error (native) 我不知道为什么它在那里寻找文件…我有一个名为“server_modules”的文件夹,但这不是我的index.html所在的位置…这是我的文件结构 – my_project – – server.js – – index.html […]

我正在得到问题phantomjs和业力

我在运行咕噜声时遇到问题,它引发了以下问题: 错误[启动]:PhantomJS2失败2次(超时)。 放弃。 DEBUG [karma]:运行完成,退出。 DEBUG [启动器]:断开所有浏览器 警告:任务“业力:连续”失败。 使用–force继续。 我试图运行npm install phantomjs 这是成功的。 之后,我运行npm install ,以及再次获得上述问题

AngularJS Bootstrap – 控制台错误

我试图从AngularJS Bootstrap设置$uibModal ,但是在控制台中出现错误。 更多的在下面。 app.js: var app = angular.module('carApp', ['ui-bootstrap']); ctrl.js app.controller('carCtrl', function($scope, $http, $uibModal) { $http.get('jobs.json').success(function(data) { $scope.data = data; $scope.open = function() { var modalContent = $uibModal.open({ templateUrl: 'careersTpl.html', controller : modalContentCtrl, resolve: { items: function() { return $scope.data; } } }) } }); }); HTML: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script […]

HTML5video无法播放和媒体请求

我在MEAN STACK应用程序中工作。 我在video加载中遇到了一个问题。 我的本地服务器进行video播放,但在我的现场服务器出现以下问题。 In Firebug Url status GET home_video.mp4 206 Partial Content GET home_video.mp4 Aborted 有一件事:有时候,video在页面刷新后播放得很好。 依赖 html5 video tag nodejs server angularjs

MEAN Stack中使用node.js和angular js更新函数不起作用

你好我是平均堆栈的初学者,我想更新使用更新logging 函数我没有成功保存logging,但更新function不工作。 我想更新一个特定的对象低于id。 但它不工作。 我正在使用这个函数来更新节点js文件中的logging module.exports.useredit = function (req, res) { var user = new Usermodel(); user = req.body.dataToModify; console.log(user); user.update({ _id:user._id },user); }; 当我使用console.log(user); 更新数据显示如下 { _id: '5846692617e0575c0e0c2211', password: 123456, email: 'shahjad.ahmad89@gmail.com', name: 'shahjad232324324324', __v: 0 } 但数据不会更新。 显示何时使用的错误消息 user.update({ _id:user._id },user); 错误是 user.update is not a function</h1>↵<h2></h2>↵<pre>TypeError: user.update is not a function↵ at […]

npm无法安装angular-cli

我正在尝试通过npm安装angular-cli。 我有最近版本的Nodejs和git安装。 我不在任何代理服务器后面(通过netsh winhttp show proxy以及通过Internet Explorer局域网设置进行validation),并且我的Internet连接没有问题。 当我尝试运行 npm install -g angular-cli然后我得到以下错误 C:\Windows\system32>npm install -g angular-cli npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\ node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "angular-cli" npm ERR! node v7.3.0 npm ERR! npm v3.10.10 npm ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! syscall connect npm ERR! network connect […]

为什么需要browserify`path`定义?

链接https://github.com/jhades/angularjs-gulp-example/blob/master/gulpfile.js有使用browserify paths的gulp build-js任务定义。 我不明白它的需要…是不是可能只是将条目指定为entries: './js/**/*.js',这将导致它search所有子entries: './js/**/*.js',目录以及…而不是明确指定paths: ['./js/controllers', './js/services', './js/directives'],这是所有同一父目录的子目录? 任何提示赞赏。