Angular JS:
<form ng-submit="loginform()" class="ng-scope ng-pristine ng-valid center" name="logform"><br/><br>
<tr ng-repeat="logcred in signinfo"></tr>
<div class="form-group col-md-4">
<label form="emailinput"><b>Email</b></label>
<input type="email" class="form-control" name="uname" id="emailinput" placeholder="you@example.com" ng-model="username" >
</div>
<div class="form-group col-md-4">
<label form="pwdinput"><b>Password</b></label>
<input type="password" class="form-control" name="pwd" id="pwdinput" placeholder="*******" ng-model="password">
</div>
<a ng-click="reloadPage()" class="navbar-brand" ></a>
<div class="col-md-4">
<button type="cancel" class="btn" ng-click="toggle_cancel()">Cancel</button>
<button class="btn btn-primary">Login</button>
</div>
<br/>
</form>
HTML:
GET
我使用json创建了登录页面表单并尝试使用POST
请求进行访问。我创建了2个表单一个用于注册,另一个用于登录。我使用GET
进行签名,并且工作正常。对于登录,我使用了GET
请求,我认为这样做很简单,但非常令人困惑。我不确定是否应该使用POST
或SELECT OD.OrderDetailID,OD.OrderID,OD.ProductID,OD.Quantity,PD.Price
FROM ORDERDETAILS OD INNER JOIN PRODUCTS PD ON OD.PRODUCTID=PD.PRODUCTID
请求。我在为登录页面编写功能时遇到困难。
但是,我找不到一个例子。如果有人有任何他们可以分享的例子吗?
答案 0 :(得分:0)
您可以使用Post请求,在从html文件调用loginform的同时发送UserName和Password.Pass用户名和密码。
HTML文件
<form ng-submit="loginform(username,password)" class="ng-scope ng-pristine ng-valid center" name="logform"><br/><br>
<tr ng-repeat="logcred in signinfo"></tr>
<div class="form-group col-md-4">
<label form="emailinput"><b>Email</b></label>
<input type="email" class="form-control" name="uname" id="emailinput" placeholder="you@example.com" ng-model="username" >
</div>
<div class="form-group col-md-4">
<label form="pwdinput"><b>Password</b></label>
<input type="password" class="form-control" name="pwd" id="pwdinput" placeholder="*******" ng-model="password">
</div>
<a ng-click="reloadPage()" class="navbar-brand" ></a>
<div class="col-md-4">
<button type="cancel" class="btn" ng-click="toggle_cancel()">Cancel</button>
<button class="btn btn-primary">Login</button>
</div>
<br/>
</form>
JS档案
$scope.loginform = function(username,password){
$http({
url :'http://localhost:3000/loginfo',
method : 'POST',
data : {
"userName":username,
"password":password
}
}).then(
function successCallback(response){
console.log(response)
},
function errorCallback(response){
console.log("Error : " + response.data)
});
}
答案 1 :(得分:0)
使用http get request从json文件中获取数据。
$http.get('db.json').success(function(response) {
$scope.data= response;
});