<ion-modal-view ng-controller="NewChatCtrl as vm">
    <ion-header-bar>
        <h1 class="title">New Chat</h1>
        <div class="buttons">
            <button class="button button-clear button-positive" ng-click="vm.hideModal()">Cancel</button>
        </div>
    </ion-header-bar>

    <ion-content>
        <div ng-controller="SearchCtrl as search">
            <div class="finder" ng-class="!(search.result | isEmpty) ? 'noBottomBorder' : {}">  
                <input type="text" placeholder="car or username" ng-model="search.chatObject" style="width: 30%">
                <button class="button button-assertive" ng-click="search.chatSearching(search.chatObject)" ng-disabled="!search.chatObject">
                    Search
                </button>   
                <ion-spinner icon="ripple" ng-if="search.loading"></ion-spinner>
            </div>
            <div class="finder_results list" ng-if="!(search.result | isEmpty)" style="border-bottom: none">
                <a class="item item-avatar" ng-if="!search.result.notFound" ng-click="search.result.evidenceNumber ? vm.newChat(search.result.user) : vm.newChat(search.result.id)">
                    <img ng-src="{{search.result.photo || 'img/user.png'}}">
                    <h2>{{search.result.evidenceNumber || search.result.username}}</h2>
                    <p>Write me message</p>
                </a>
                <div class="error" ng-if="search.result.notFound">
                    <h2><i class="icon ion-android-remove-circle"></i> {{search.result.error}}</h2>
                </div>
            </div>
        </div>
    </ion-content>
</ion-modal-view>