angularjs - Two way databinding does not work in <ion-content> -


two way databinding not woking in <ion-content>. not able updated value of $scope variable ("searchkeyword" in case). if put html outside <ion-conent> works. confused 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 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 don't updated value of "searchkeyword". below controller,

angular.module('myapp') .controller('searchcontroller',function($scope){ $scope.searchkeyword='';   $scope.search=function(){     console.log('search keyword : '+$scope.searchkeyword);   }; }) 

$scope.searchkeyword in search() , ng-model refer different scopes after value of input has changed, because <ion-content> creates new scope. unfortunately, primitive values, needs worked around. please see this answer deeper explanation.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -