我正在尝试将护照整合到我的代码的登录表单中.客户端呼叫服务器端工作正常,直到我在请求中调用passport.authenticate,返回400 Bad Request.我在这里想念的是什么
HTML
<div>
<div class="row">
<div class="input-field col s12">
<input id="user-email" type="text" ng-model="user.email">
<label for="user-email">Your email address</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="user-password" type="password" ng-model="user.password">
<label for="user-password">Your password</label>
</div>
</div>
<div id="login-button-panel" class="center-align">
<button class="btn" id="login-btn" ng-click="vm.login(user);">Login</button>
</div>
<div class="section center">
<a class="modal-trigger">Forgot password?</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
JS
$http.post('/api/login',user).success(function(result){
console.log(result)
})
Run Code Online (Sandbox Code Playgroud)
server.js
passport.use(new LocalStrategy(
function(username, password, done) {
return done(null, false, {message:'Unable to login'})
}
));
passport.serializeUser(function(user,done){
done(null,user);
});
passport.deserializeUser(function(user,done){
done(null,user);
});
app.post('/api/login', passport.authenticate('local'), function(req,res){ …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用html2canvasusing截取屏幕截图ionicframework。除了我有:before. 如
CSS
.e_amount::before{
content: "$";
}
Run Code Online (Sandbox Code Playgroud)
在html2canvas 代码之后:
注意到美元符号 ($) 与 10.00 不一致。
我试过在头部包含样式,但仍然无法正常工作。我错过了什么?
JS
html2canvas(document.getElementById('card'), {
onrendered: function(canvas) {
window.canvas2ImagePlugin.saveImageDataToLibrary(
function(msg){
console.log(msg);
var message = {
text: "QR Generated",
image: "file://"+msg
};
window.socialmessage.send(message);
},
function(err){
console.log(err);
},
canvas
);
}
});
Run Code Online (Sandbox Code Playgroud)
html
<div class="list card" id="card">
<div class="item item-body">
<div class="row" style="margin-bottom: 5px; border-bottom: 1px solid #ddd;">
<style>.e_amount::before{content:'$' !important;}</style>
<div class="col bold">{{"amount" | translate}}</div>
<div class="col e_amount"></div> …Run Code Online (Sandbox Code Playgroud) 我想在模型中要求我的模型.我确信我的要求路径是正确的,因为我的要求没有错误,但似乎每当我保存新实例时它都不会触发我的模型.我在这里错过了什么?
role.js
module.exports = function () {
var mongoose = require('mongoose'),
Schema = mongoose.Schema;
var role = new Schema({
type: String,
level: Number,
});
role.pre("save",function(next) {
this.type = 'member';
this.level = 0;
next();
});
return mongoose.model('Role', role);
}
Run Code Online (Sandbox Code Playgroud)
user.js的
module.exports = function (connection) {
var mongoose = require('mongoose');
Role = require('./role.js'),
Schema = mongoose.Schema;
var user = new mongoose.Schema({
first_name: String,
last_name: String,
email: String,
password: String,
profile_image: String,
company_name: String,
type: [{ type : String, default: 'Local' }],
created_at: …Run Code Online (Sandbox Code Playgroud) 我正在尝试加入两个集合并能够获取合并的数据。要使用Mongoose做到这一点,我应该使用填充语法来实现这一点。我收到未为“ User_Fb”注册架构模式的错误。从我的代码中,我已经导出了模型,并且在server.js中需要它,但是错误仍然出现。我做错了什么?
feed_post.model.js
var mongoose = require('mongoose');
var conn_new_app = mongoose.createConnection('mongodb://localhost/new_app');
var User_fb = require('../models/fb_db.model');
var Schema = mongoose.Schema;
var feed_postSchema = new Schema({
user_id: { type: Schema.Types.ObjectId, ref: 'User_Fb' },
content: String,
location: String,
image: [{ type : String }]
});
var Feed_Post = conn_new_app.model('Feed_Post', feed_postSchema);
module.exports = Feed_Post;
Run Code Online (Sandbox Code Playgroud)
fb_db.model.js
var mongoose = require('mongoose');
var conn_new_app = mongoose.createConnection('mongodb://localhost/new_app');
var Feed_Post = require('../models/feed_post.model');
var user_fb = new mongoose.Schema({
name: String,
location: String,
fb_id: Number
});
var User_Fb = conn_new_app.model('User_Fb', user_fb); …Run Code Online (Sandbox Code Playgroud) 我试图检测foreach语句是否与foreach中的语句一起完成.根据我的研究,许多人都要求使用承诺.当我实现它时,它没有按照我期望的方式执行.
var uploadUrl = "/api/upload";
$('#add_product').closeModal();
var promises = angular.forEach(vm.images_selected, function(value , key){
return File_Upload.uploadFileToUrl(value, uploadUrl)
.success(function(result){
vm.images_selected_uploaded.push(result);
console.log('here')
});
})
$q.all(promises).then(function () {
console.log('there')
console.log(vm.images_selected_uploaded)
})
Run Code Online (Sandbox Code Playgroud)
从上面的代码(假设值长度为2,输出将是
there
here
here
Run Code Online (Sandbox Code Playgroud)
我真正想要的是在这里.我在这里错过了什么?
我是创建Windows Phone 8应用程序的新手.我想创建一个跟踪我日常活动的日历应用程序.我知道日历应用程序中已经有一个版本,但我想尝试在我自己的用户界面中创建自己.
有没有办法获得日历的日期.例如,使用API构建来访问我不必创建自己的日期,例如在我自己的函数中创建一个全新的日历应用程序.我将不得不考虑闰年,哪个月有31天,哪个没有.我做了一些研究,但我得到的最多的是能够从日历中的构建中访问约会.如果我的理论有任何不妥之处,请纠正我.