index.html
<div class="login" ng-show="isAdmin">
管理员登陆<br>
<input type="text" placeholder="Name" ng-model="formData.adminuser"/><br>
<input type="text" placeholder="Password" ng-model="formData.adminpassw"/><br>
<button ng-click="login()">登陆</button>
</div>
app.js
$scope.login = function() {
$http.post('/login', $scope.formData)
.success(function(data) {
//console.log(data);
if(data=="true"){
alert("登陆成功");
}else{
alert("登陆失败");
}
})
}
index.js
//登陆
app.post('/login', function(req, res) {
var admin = req.body.adminuser;
var passw = req.body.adminpassw;
console.log(admin);
console.log(passw);
if (admin == "admin" && passw == "111") {
res.send(true);
}else{
res.send(false);
}
});