Input value doesnt update

View:

<ion-view cache-view="false" view-title="Ustawienia" >
    <ion-content ng-controller="AccountCtrl">
        <div class="list">
            <label class="item item-input item-floating-label">
                <span class="input-label">Adres serwera</span>
                <input type="text" placeholder="Adres serwera">
            </label>
            <label class="item item-input item-floating-label">
                <span class="input-label">Klucz API</span>
                <input type="text" ng-model="apikey"  placeholder="Klucz API">
            </label>
        </div>
        <div class="padding">
            <button ng-click="scan()" class="button button-block button-energized">
                Skanuj Kod
            </button>
            <button class="button button-block button-positive">Zapisz</button>
        </div>
    </ion-content>
</ion-view>

Controller:

.controller('AccountCtrl', function($scope) {
/*    $scope.settings = {
        enableFriends: true
    };*/
    $scope.apikey = '';
    //scan
    $scope.scan = function () {
        //$scope.apikey.value = "test";
        cordova.plugins.barcodeScanner.scan(
         function (result) {
             $scope.apikey= result.text;

         },
         function (error) {
             alert("Błąd podczas skanowania!");
         }
      );
    };
    console.log($scope.apikey);
});

Input value doesn't change after scanning. If i change tab in menu input value change. Any refresh problem or what? I want after scanning change input value.

You have to wrap your code with $scope.apply cause the framework needs to perform the proper scope life-cycle.

$scope.scan = function () {
    //$scope.apikey.value = "test";
    cordova.plugins.barcodeScanner.scan(
     function (result) {
        $scope.apply(function() {
             $scope.apikey = result.text;
        }); 
     },
     function (error) {
         alert("Blad podczas skanowania!");
     }
   );
};

You can read more about it in the official documentation.