How to get the input value to pass it through ajax? - This is solved LOGIN VALIDATION THROUGH SERVER-SIDE


#1
        <form name="loginForm"  ng-controller="LoginController" ng-submit="LoginFormaction(user);" >
            <div class="list list-inset">
                <label class="item item-input">
                    <input type="email" placeholder="E-mail" ng-modal="user.emailLog">
                </label>
                <label class="item item-input">
                    <input type="password" placeholder="Password" ng-modal="user.passLog">
                </label>
            </div>
            <div class="padding">
                <div><span class="error_forget">{{login_error}}</span><span class="valid_forget">{{login_success}}</span></div>
                <button type="submit" class="button button-block button-positive">Login</button>                  
            </div>
        </form>

var app = angular.module(‘massmutual’, [‘ionic’]);

app.controller(‘LoginController’,function($scope,$http){
$scope.login_error = ‘’;
$scope.login_success = ‘’;

$scope.LoginFormaction = function(user){
    alert($scope.user.emailLog);
    $scope.login_error = '';
    $scope.login_success = '';
    $http.post('login/validorin_login',{'logemails':$scope.user.emailLog,'logpasss':$scope.user.passLog}
    ).success(function(data, status, headers, config) {
            if (data.msg != '')
            {
                $scope.login_success='success';
            }
            else
            {
                $scope.login_error='Invalid Email Address/Password';
            }
        }).error(function(data, status) {
            $scope.login_error='Invalid Email Address/Password';
        });
}

})


#2

This is solved

here is the below code which checks with the backend validation for login using codeigniter

app.controller(‘LoginController’,function($scope,$http){
$scope.login_error = ‘’;
$scope.login_success = ‘’;

$scope.LoginFormbut = function(){

    $scope.login_error = '';
    $scope.login_success = '';

    var emailLog=$scope.emailLog!=null?$scope.emailLog:'';
    var passLog=$scope.passLog!=null?$scope.passLog:'';
    alert(emailLog+' '+passLog);
    if(emailLog!='' && passLog!='')
    {
        alert($scope.emailLog);
        $http.post('login/validorin_login',{'logemails':$scope.emailLog,'logpasss':$scope.passLog}
        ).success(function(data, status, headers, config) {
                if (data.msg != '')
                {
                    $scope.login_success='success';
                }
                else
                {
                    $scope.login_error='Invalid Email Address/Password';
                }
            }).error(function(data, status) {
                $scope.login_error='Invalid Email Address/Password';
            });
    }
    else
    {
        $scope.login_error='Invalid Email Address/Password';
    }

}

})

                </label>
                <label class="item item-input">
                    <input type="password" placeholder="Password" ng-model="passLog">
                </label>
            </div>
            <div class="padding">
                <div><span class="error_forget">{{login_error}}</span><span class="valid_forget">{{login_success}}</span></div>
                <button type="button" class="button button-block button-positive"  ng-click="LoginFormbut();">Login</button>
          
            </div>
        </form>

#3

Glad it’s working! :slight_smile:


#4

Just from 2days learnt many things. Many things are not documented yet.


#5

this is what i am looking for


#6

why i can’t get value of ng-modle:

{{login_error}}{{login_success}}
登录

app.controller(‘LoginController’,function($scope,$http){
$scope.login_error = ‘’;
$scope.login_success = ‘’;

    $scope.login = function(){
		$scope.login_error = '';
		$scope.login_success = '';
		alert($scope.username);


#7

Specify as ng-model in HTML code.


#8

well,i took the wrong word modal in your reply.


#9

@liuguichuan666 Is your problem is solved or having any doubts