我使用Angularjs创建一个登录页面。但是当我输入错误的数据时它也显示下一页((在.Success()Url中)。 [英] I Create A Login Page With Angularjs. But When I Input Wrong Data It Also Show The Next Page((In .Success() Url )).
本文介绍了我使用Angularjs创建一个登录页面。但是当我输入错误的数据时它也显示下一页((在.Success()Url中)。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用angularjs创建一个登录页面。但是当我输入错误的用户名和错误的密码时,它也显示下一页((在.success()url中))
例如: -
i create a login page with angularjs. but when i input wrong user name and wrong password it also show the next page((in .success() url ))
example:-
var FirstAngular = angular.module('myApp', []);
FirstAngular.controller('Login', function ($scope, $http) {
//search login
$scope.searchlogin = function () {
debugger;
$http({
dataType: 'jsop',
method: 'POST',
url: '../WebService.asmx/adminsearch',
data: {
'Name': $scope.Name,
'Password': $scope.Password,
},
contentType: 'application/json; charset=utf-8',
})
.success(function (data, status, headers, config) {
window.location.href = 'home.html';
})
.error(function (data) {
alert('error');
});
}
网络服务: -
web service:-
public string adminsearch(string Name,string Password)
{
conn.Open();
string query = "select * from admin_login where admin_id='"+Name+"' and passwords='"+Password+"' ";
SqlCommand cmd = new SqlCommand(query, conn);
DataTable t1 = new DataTable();
using (SqlDataAdapter a = new SqlDataAdapter(cmd))
{
a.Fill(t1);
}
//string jsonformat;
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
foreach (DataRow dr in t1.Rows)
{
row = new Dictionary<string, object>();
foreach (DataColumn col in t1.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
return serializer.Serialize(rows);
}
推荐答案
范围,
http){
// 搜索登录
scope.searchlogin = function (){
debugger ;
scope.searchlogin = function () { debugger;
这篇关于我使用Angularjs创建一个登录页面。但是当我输入错误的数据时它也显示下一页((在.Success()Url中)。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文