MobileFirst: How to pass parameters to adaptor using angularJS -
i using angularjs in mobile first , getting error parameter values not recevied adaptor
need know how pass parameters in function(function($scope.username, $scope.password)) & parameter(parameters : [$scope.username, $scope.password])
variable using $scope
or without $scope
app.controller('logincontroller',function($scope){ $scope.login = function($scope.username, $scope.password){ $scope.usernametxt = angular.element('#usrname').val(); $scope.passwordtxt = angular.element('#pass').val(); console.log($scope.username, $scope.password); $scope.username = $scope.usernametxt; $scope.password =$scope.passwordtxt; $scope.loginprocedure = { procedure : 'login', adaptor : 'sql', parameters : [$scope.username, $scope.password] }; wl.client.invokeprocedure($scope.loginprocedure,{ onsuccess : $scope.loginsuccess, onfailure : $scope.loginfailure }); $scope.loginsuccess = function(data) { $scope.data = data; console.log($scope.data); }; $scope.loginfailure = function() { console.log('failed'); }; } });
two-way binding
if using two-way binding in controller shown below
<div ng-controller="logincontroller"> <form ng-submit="login()"> <input type="text" ng-model="username" placeholder="username" /> <input type="password" ng-model="password" placeholder="password" /> <input class="btn-primary" type="submit" value="login" /> </form> </div>
then can use following:
app.controller('logincontroller',function($scope){ $scope.login = function(){ $scope.loginprocedure = { procedure : 'login', adapter : 'sql', parameters : [$scope.username, $scope.password] }; wl.client.invokeprocedure($scope.loginprocedure,{ onsuccess : $scope.loginsuccess, onfailure : $scope.loginfailure }); $scope.loginsuccess = function(data) { $scope.data = data; console.log($scope.data); }; $scope.loginfailure = function() { console.log('failed'); }; } });
no binding:
if not using two-way binding form fields try following:
app.controller('logincontroller',function($scope){ $scope.login = function(){ var username = angular.element('#usrname').val(); var password = angular.element('#pass').val(); $scope.loginprocedure = { procedure : 'login', adapter : 'sql', parameters : [username, password] }; wl.client.invokeprocedure($scope.loginprocedure,{ onsuccess : $scope.loginsuccess, onfailure : $scope.loginfailure }); $scope.loginsuccess = function(data) { $scope.data = data; console.log($scope.data); }; $scope.loginfailure = function() { console.log('failed'); }; } });
Comments
Post a Comment