ng-click event is not firing on button click?

Amit Sharma

i'm creating web application in Angularjs i write code in separate .js file for log in from database is is execute on page load but not triggering on button click, my .js code is:

var adminModule = angular.module('angApp', []);
//Defining a Angular Controller
adminModule.controller('AdminCtrl', ['$scope', '$http',
    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;
            });
        }
    }]);

and my view as what i'm using for binding this using Angularjs here is an issue above code is working on page load but don't work on button click, the code i use is:

<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>

anyone please help me what i miss here so i'm not able to trigger ng-click event on button click thanks in advance.

sma

Your Login function needs to be on a scope. Right now, its essentially a private function:

$scope.Login = function () {
  ...
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Jquery button click event not firing

From Dev

Button Click event not firing for dynamically created button

From Dev

ng-click event is not firing on span element

From Dev

angular ng-click event not firing

From Dev

Ionic/AngularJS ng-click event not firing?

From Dev

angular ng-click event not firing

From Dev

Event handler not firing on dynamic button click

From Dev

Backbone js button click event not firing

From Dev

Jquery ajax button click event firing twice?

From Dev

My Button_click event is not firing in datalist

From Dev

jQuery click event not firing for dialog button

From Dev

button click event is not firing in a pop up window

From Dev

Event handler not firing on dynamic button click

From Dev

Button onclick event not firing on first click

From Dev

C# Dynamic button not firing click event

From Dev

jQuery on(click)/click event not firing

From Dev

AngularJS ng-click event not firing within ng-repeat

From Dev

jquery on Click event not firing

From Dev

BackboneJS click event not firing

From Dev

jQuery 'click' event not firing

From Dev

Click event not firing using ON?

From Dev

The on click event is not firing

From Dev

Knockout Click event not firing

From Dev

click event on anchor not firing

From Dev

Dynamic button not firing click event or page life cycle for button(not dynamic)

From Dev

jQuery click not firing for button

From Dev

ng-click event inside the bootstrap modal not firing

From Dev

Button click event not firing when inside form tags

From Dev

Windows Store App Button Click Event Not Firing with Grid Template