Two way databinding is not woking in <ion-content>
. I am not able to get updated value of $scope variable ("searchKeyword" in this case). If i put the html outside the <ion-conent>
then it works. I am very confused about this behavior.Below code works,
<ion-view view-title="Search" >
<div class="bar bar-header item-input-inset" style="height:52px;">
<label class="item-input-wrapper">
<i class="icon ion-ios-search placeholder-icon"></i>
<input type="search" placeholder="Search" ng-model="searchKeyword" ng-keyup="$event.keyCode == 13 ? search() : null">
</label>
<button class="button button-clear" ng-click="search()">
search
</button>
</div>
<ion-content scroll="true" style="margin-top:50px;" >
</ion-content>
</ion-view>
but below does not :(
<ion-view view-title="Search" >
<ion-content scroll="true" style="margin-top:50px;" >
<div class="bar bar-header item-input-inset" style="height:52px;">
<label class="item-input-wrapper">
<i class="icon ion-ios-search placeholder-icon"></i>
<input type="search" placeholder="Search" ng-model="searchKeyword" ng-keyup="$event.keyCode == 13 ? search() : null">
</label>
<button class="button button-clear" ng-click="search()">
search
</button>
</div>
</ion-content>
</ion-view>
Here, on search() function i don't get updated value of "searchKeyword". Below is my controller,
angular.module('myapp')
.controller('SearchController',function($scope){
$scope.searchKeyword='';
$scope.search=function(){
console.log('search keyword : '+$scope.searchKeyword);
};
})