我安装了Angular-CLI,但它显示错误.当我创建一个新项目时__CODE__,我收到此错误:
ng n app
Run Code Online (Sandbox Code Playgroud)
所以我想卸载Angular-CLI.
我正在开发一个基于angular.js + node.js并mongodb使用快速模板的简单博客网站.我$http通过POST方法从角度控制器命中到一个名为api的api users.js,其中login使用passport.authenticate方法进行身份验证.我需要护照本地登录策略users.js.
但它不起作用.角度登录服务代码和节点用户api代码.任何人都可以告诉我如何passport.js在角度和节点中使用?
通过服务进行角度路由
app.service('Auth',function($location,$http,$localStorage){
var userLogin ;
return{
setLogIN:function(email,password){
$http({
method: 'POST',
url: '/users/login', //users.js having node routing.
data: {email:email, password:password},
})
Run Code Online (Sandbox Code Playgroud)
用户中的节点路由
router.post('/login',passport.authenticate('local', {
// use passport-local for authentication
successRedirect : '/profile',
failureRedirect : '/login',
failureFlash : true
}));
Run Code Online (Sandbox Code Playgroud)
护照本地策略
app.use(passport.initialize());
app.use(passport.session());
passport.use(new LocalStrategy(
function (username, password, done) {
User.findOne({username: username}, function (err, user) {
if (err) {
return done(err);
}
if (!user) …Run Code Online (Sandbox Code Playgroud) 我是AngularJS的新手,我对此代码有疑问.我想在单个中添加多个控制器ng-app.但它执行第一个.为什么不是第二个?
<!DOCTYPE html>
<html ng-app="myapp">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angul /1.4.8/angular.min.js"></script>
</head>
<body>
<div ng-controller="cont1">
<input type="text" ng-model="fullname">
{{fullname}}
</div>
<div ng-controller="cont2">
<input type="text" ng-model="fname">
{{fname}}
</div>
<script>
var app = angular.module("myapp", []);
app.controller('cont1', function ($scope) {
$scope.fullname = "";
});
var new = angular.module('myapp', []);
new.controller('cont2', function ($scope) {
$scope.fname = "";
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我正在进行节点+ passport.js身份验证.我做了一个简单的登录/注册应用程序.它工作正常,但它只存储用户名和密码.
如何通过带有工作登录护照身份验证的signup.html页面将其他表单字段(如电话号码,电子邮件,爱好,性别)存储到数据库中?任何人都可以有解决方案,所以我可以存储数据库中的所有字段....
//my schema is :--
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var userSchema = mongoose.Schema({
local : {
username : String,
gender : String,
phone : String,
email : String,
password : String
}
});
userSchema.methods.generateHash = function(password) {
return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
};
userSchema.methods.validPassword = function(password) {
return bcrypt.compareSync(password, this.local.password);
};
var User = mongoose.model('user', userSchema);
module.exports = User;
Run Code Online (Sandbox Code Playgroud)
在此代码中,我使用电子邮件,用户名,密码,性别电话的架构以及signup.html页面中的字段.但它只存储用户名和密码字段.........