Use model attribute as ng-if condition, get error

The error is when I use model's attribute as a condition in angular ng-if directive. It occurs an error which is

TypeError: Cannot read property 'then' of undefined

And my html is:

 <div class="item-input-wrapper">
   <i class="icon ion-ios7-search placeholder-icon"></i>
   <input type="search" ng-model="keywords" placeholder="Search" >
   <button ng-if="keywords.length"
    class="button button-icon ion-ios7-close-outline input-button"
    ng-click="clearSearchWords()">
   </button>
 </div>

I have tried to copy this code in an new ionic project, and it can be executed in other project perfectly. Ng-if is a build-in angular directive. Why it could result in different outputs? And is that any approach to solve it?