我在
Angularjs中创建Web应用程序,我在单独的.js文件中编写代码,用于从数据库登录
是在页面加载时执行但在按钮点击时不触发,
我的.js代码是:
是在页面加载时执行但在按钮点击时不触发,
我的.js代码是:
- var adminModule = angular.module('angApp',[]);
- //Defining a Angular Controller
- adminModule.controller('AdminCtrl',['$scope','$http',`enter code here` function ($scope,$http) {
- Login();
- function Login(U_Name,U_PWD) {
- debugger;
- //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;
- });
- }
- }]);@H_301_4@
我在这里使用Angularjs用于绑定它的视图是一个问题,上面的代码正在处理页面加载但是不能按下按钮,我使用的代码是:
<div class="admin-login" ng-controller="AdminCtrl" ng-app="angApp"> <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>@H_301_4@有人请帮助我,我想念这里,所以我无法点击按钮触发ng-click事件
提前致谢.