I’ve got some problem with binding my data to my view with angularjs in the ionic framework.
This is my controller.js:
.controller('InventoryCtrl', function($scope, Category, Inventory) {
$scope.categories = Category;
$scope.searchInventory = function(category){
var word = category.Category;
var ref = new Firebase('https://vivid-heat-2430.firebaseio.com/');
var invenRef = ref.child('Inventories');
var prodRef = invenRef.child('Products');
invenRef.orderByChild("Products").on("child_added", function(snapshot) {
var data = snapshot.val();
var store = data.Inventory;
var prod = data.Products;
var test = Object.keys(prod);
for( var i = 0; i < test.length; i++){
if (test[i] == word) {
console.log(test[i]);
console.log("Storage place: " + data.Inventory + " Datum inventaris: " + data.Date);
$scope.show= test[i];
};
};
});
};
})
Here I’m getting my products from my array. Then I’m comparing it. It will give me the matching objects and it will also give me the storage place where it belongs to. I can log this in my console. But when I’m trying to bind it to my view. It gives me nothing.
this is my index.html:
<ion-content>
<p><b>Zoek categorie</b></p>
<ion-scroll direction="y" >
<div style="max-height: 300px" ng-controller="InventoryCtrl">
<ion-list>
<ion-radio ng-repeat="category in categories" class="item-accordion" ng-model="checked.check" value="{{category.Category}}" ng-click="searchInventory(category)">
<p>{{category.Category}}</p>
</ion-radio>
<br>
</ion-list>
</div>
<div>
<ion-list>
<ion-item>
{{show}}
</ion-item>
</ion-list>
</div>
</ion-scroll>
</ion-content>
And I don’t understand what I did wrong… Is it because my $scope.show is still inside the .on method?