我用角度js创建了一个电子商务网站.我需要在亚马逊网络服务中托管相同的内容.
所以为了主持相同的我首先创建了一个ec2实例.之后,通过允许所有ip作为出站和入站,添加了一个带有VPC安全组的rds实例.在创建我为mysql和所有连接指定的安全组时.在我远程进入实例并尝试使用rds实例连接到终点之后
mysql -u username -p password -h ********.ap-southeast-1.rds.amazonaws.com:3306
Run Code Online (Sandbox Code Playgroud)
我收到一个错误
ERROR 2005 (HY000): Unknown MySQL server host xxxxxxxxx (0)
Run Code Online (Sandbox Code Playgroud)
我从亚太地区(新加坡)地区创建了这个实例,因为我是印度居民.
我正在使用node / express服务器和angularjs作为前端。服务器设置cookie,并在网络响应中正确显示。但Cookie不会显示在chrome开发人员工具的“资源”标签中。可能的原因是什么?
我有这个mongoose架构
var ContactSchema = module.exports = new mongoose.Schema({
name: {
type: String,
required: true
},
phone: {
type: Number,
required: true,
},
messages: [
{
title: {type: String, required: true},
msg: {type: String, required: true}
}],
address:{ city:String,
state:String
}
});
Run Code Online (Sandbox Code Playgroud)
我最初收集了名称和电话字段.我需要将带有新消息的集合更新为messages数组,将新地址更新为address对象.该函数还必须处理任何单个操作,即在某些情况下我只更新消息数组或更新名称和地址.所以我怎么能在一个功能中完成所有操作.
var messages= {
title: req.body.title,
msg: req.body.msg
}
Model.findOneAndUpdate({'_id': req.body.id,},{$push: {messages:message}},{upsert: true}, function (err, data) {
if (err) {
return res.status(500).send(err);
}
if (!data) {
return res.status(404).end();
}
return res.status(200).send(data);
});
Run Code Online (Sandbox Code Playgroud) 我正在研究ui网格编辑单元格功能.我需要使用rest api将编辑的单元格值更新到数据库.另外,我如何获得在控制器中选择的行列表.
我的工作代码
var app = angular.module('app', ['ngTouch', 'ui.grid', 'ui.grid.edit']);
app.controller('MainCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.gridOptions = { };
$scope.gridOptions.columnDefs = [
{ name: 'id', enableCellEdit: false},
{ name: 'name' },
{ name: 'age', displayName: 'Age' , type: 'number', width: '10%' }
];
$http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json')
.success(function(data) {
$scope.gridOptions.data = data;
});
}])
Run Code Online (Sandbox Code Playgroud)
我需要根据某些条件改变角度ui网格的行颜色.如图所示,目标在ng-grid中实现
rowTemplate: '<div style="height: 100%" ng-class="{red: row.getProperty(\'viewed\') < 1}"><div ng-style="{ \'cursor\': row.cursor }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngCell ">' +
'<div class="ngVerticalBar" ng-style="{height: rowHeight}" ng-class="{ ngVerticalBarVisible: !$last }"> </div>' +
'<div ng-cell></div>' +
'</div></div>',
Run Code Online (Sandbox Code Playgroud)
如何在角度ui网格中实现相同
跨域请求时未设置 cookie。我的服务器在 localhost:8000 中运行,客户端在 localhost:9000 中运行。服务器nodejs/express上的cors设置是
app.use(function(req, res, next) {
console.log(req.method);
res.header("Access-Control-Allow-Origin", "*");
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Cache-Control, Authorisation");
if (req.method === 'OPTIONS') {
return res.send(200);
} else {
return next();
}});
Run Code Online (Sandbox Code Playgroud)
客户端使用Angualarjs,cors配置为
SelappsAdmin.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
}])
Run Code Online (Sandbox Code Playgroud) angularjs ×4
cookies ×2
node.js ×2
amazon-ec2 ×1
amazon-rds ×1
amazon-vpc ×1
arrays ×1
cross-domain ×1
express ×1
mongodb ×1
mongoose ×1
mysql ×1
ng-grid ×1