My Code :
HTML
<body ng-app="loginApp" ng-controller="loginCtrl" >
<div class="loginWrap" >
<input type="text" placeholder="Username " ng-model="user" />
<input type="text" placeholder="Password " ng-model="pass" />
<input type="button" value="Login" ng-click="checkLogin()" />
<span ng-bind="resultLog"></span>
</div>
</body>
Angular Code :::
var appLog = angular.module('loginApp',[])
.controller('loginCtrl',function($scope,$http){
$scope.checkLogin = function(){
if($scope.user.length > 0 && $scope.name.length > 0 )
{
$http.post('php/checkLogin.php',{'n':$scope.user, 'p':$scope.pass})
.success(function(data)
{
if(data)
{
$scope.resultLog = "Valid"
}
else
{
$scope.resultLog = "InValid"
}
})
.error(function()
{
$scope.resultLog="Error"
})
}
else
{
$scope.resultLog = "Fill All Fields";
} // end of validation
} })
I am learning angular JS.. and execute some..
Problem :: $scope.resultLog
Not working
Scope Obejct not working inside the function.. it is declare in LoginCtrl and i m using inside the function, declare inside the LoginCtrl
Thanks in advance
user
andname
other wise it will beundefined
so you cannot check the length of undefined – Nidhish Krishnan Apr 3 '14 at 8:46