Angularjs Data Binding Not Working With Ionic
I feel like I am missing something obvious with some input text in ionic. I am using angular-ui-router with this route: $stateProvider.state('findPersons', { url : '/findPerson
Solution 1:
You need to be using "dot notation". Because of inheritance, simple values will not do two way binding.
Please use the following code for two way data binding with ionic
In controller
$scope.test={keyWord : ""};
In view
<div class="bar bar-header item-input-inset">
<labelclass="item-input-wrapper"><iclass="icon ion-search placeholder-icon"></i><inputtype="search"placeholder="Key Word"ng-model="test.keyWord"></label><buttonng-click="findPersons()"class="button button-bar-inline">Load</button></div>
Live Example are here & same issue are here.
Read more details from here.
Hope this well help!
Solution 2:
Find the below code everything works fine. Possible errors
URL in the $http call is in two lines. Fix it.
var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope,$http) { $scope.name = 'World'; $scope.results= null; $scope.numberOfResults=-1; $scope.keyWord=""; $scope.findPersons = function() { var URL= "http://localhost:8080/bockmoi/rest/findPersons?keyWord="+$scope.keyWord+'&page=0&size=2'; console.log(URL); $http({ method : 'GET', url : 'http://localhost:8080/bockmoi/rest/findPersons?keyWord='+$scope.keyWord+'&page=0&size=2' }).then(functionsuccessCallback(response) { $scope.results = response.data; $scope.numberOfResults=$scope.results.numberOfElements; },functionerrorCallback(response) { }); } });
I tried printing your URL after the button click as in the above code and the behaviour is as expected.
Solution 3:
I tried your code, but I could not reproduce your problem. Sorry :( . Just a plus, whether you would like to improve you code, you can follow john papa's advices https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md
Post a Comment for "Angularjs Data Binding Not Working With Ionic"