【发布时间】:2014-10-31 06:57:09
【问题描述】:
在我的 Angularjs MVC 应用程序中,我为登录编写代码,它接受来自两个文本框的值作为用户名和密码 我的 Angularjs 控制器代码工作正常,但视图有问题
$scope.Login = function Login(U_Name, U_PWD) {
//Defining the $http service for login the admin user
$http({
method: 'POST',
url: '/Admin/IsAuthenticate',
data: { User_Name: U_Name,
User_PWD: U_PWD }
}).success(function (result) {
if (result == true) {
alert('user is valid');
}
else {
alert('unauthorised access!');
}
})
.error(function (error) {
//Showing error message
$scope.status = 'Unable to connect' + error.message;
});
}
此代码在 ng-click 事件上执行,但不接受来自输入框的值 我的视图代码如下:
<div ng-app="angApp">
<div ng-controller="AdminCtrl">
<div class="admin-login">
<h2>using angularjs</h2>
<input type="text" id="txtUserAng" placeholder="User Name" ng-model="U_Name" />
<input type="password" id="txtPWDAng" placeholder="Password" ng-model="U_PWD" />
<input type="button" id="login" value="login" ng-click="Login()" />
</div>
</div>
</div>
【问题讨论】:
标签: angularjs angularjs-directive angularjs-scope