2017-07-14 37 views
-1

我正在開發離子v1應用,其中,當我輸入手機號碼時,網絡名稱和圈子名稱應該在下拉菜單中自動更新像PayTM等應用程序...手機號碼應該自動獲取網絡名稱和圈子 - Ionic 1

我有一個數據庫已經在其中網絡已被拆分的移動號碼的前4位數。如何在輸入手機號碼時傳遞請求?

請提出一些想法來做到這一點。

enter image description here

回答

0

的細節,你可以使用角度1納克變化

View.html

<input type="text" ng-model="mobilenumber" ng-change="updateotherfields()" /> 

Controller.js

app.controller('yourCtrl', function($scope) { 
    $scope.mobilenumber; 
    $scope.updateotherfields = function(){ 

     if($scope.mobilenumber){ 
     //check the length 

     if($scope.mobilenumber.length > 4){ 
      console.log($scope.mobilenumber); 
     var firstfournumbers = $scope.mobilenumber.slice(0, 4); 

     //now you have your fournumbers 
     //Do you server code and then update the combobox Model 

     } 


} 

    } 

}); 
0
<!DOCTYPE html> 
<html> 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> 
<body> 

<div ng-app="myApp" ng-controller="formCtrl"> 
<form> 
    First Name: <input type="text" ng-model="number"> 
    </form> 
    <button ng-click="submit(number)">Check</button> 
</div> 

<script> 
var app = angular.module('myApp', []); 
app.controller('formCtrl', function($scope) { 
    $scope.number; 
    $scope.submit = function(number){ 
     console.log(number) 
     var res = number.slice(0, 4); 
     console.log(res) 
    } 

}); 
</script> 

</body> 
</html> 

發送 '資源' 的價值服務器,搜索db表使用4位數的值,獲得網絡