Firebase.
I have converted the controller over and it is working to display the data
from firebase.
OLD PHP Endpoint
app.controller('InstantSearchController', ['$scope', '$http', function($scope, $http) {
$http.get('inc/api.php').success(function(itemData) {
$scope.items = itemData;
});}]);
New Firebase Endpoint
app.controller('InstantSearchController', ['$scope', '$firebase', function($scope, $firebase) {
var medRef = new Firebase("https://dazzling-fire-####.firebaseio.com/");
$scope.items = $firebase(medRef);}]);
But I am not 100% sure how to swap the app.filter over to use the firebase
data.
Here is what it was with the PHP End Point
app.filter('searchFor', function(){
return function(arr, searchString){
if(!searchString){
return arr;
}
var result = [];
searchString = searchString.toLowerCase();
angular.forEach(arr, function(item){
if(item.english.toLowerCase().indexOf(searchString) !== -1){
result.push(item);
}
if(item.spain.toLowerCase().indexOf(searchString) !== -1){
result.push(item);
}
if(item.germany.toLowerCase().indexOf(searchString) !== -1){
result.push(item);
}
if(item.france.toLowerCase().indexOf(searchString) !== -1){
result.push(item);
}
if(item.philippines.toLowerCase().indexOf(searchString) !== -1){
result.push(item);
}
});
return result;
};
});
And this is what I was thinking "should" work but it doesn't, from doing
some reading and watching of some tutorials i thought that i needed to
switch item with id
app.filter('searchFor', function(){
return function(arr, searchString){
if(!searchString){
return arr;
}
var result = [];
searchString = searchString.toLowerCase();
return function(arr, searchString){
if(!searchString){
return arr;
}
var result = [];
searchString = searchString.toLowerCase();
angular.forEach(arr, function(id){
if(id.english.toLowerCase().indexOf(searchString) !== -1){
result.push(item);
}
if(id.spain.toLowerCase().indexOf(searchString) !== -1){
result.push(item);
}
if(id.germany.toLowerCase().indexOf(searchString) !== -1){
result.push(item);
}
if(id.france.toLowerCase().indexOf(searchString) !== -1){
result.push(item);
}
if(id.philippines.toLowerCase().indexOf(searchString) !== -1){
result.push(item);
}
});
return result;
};});
Any help pointing me in the right direction would be great i am really
trying to learn this AngularJS/Firebase stuff!
--
You received this message because you are subscribed to the Google Groups "Firebase + AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-angular+unsubscribe@googlegroups.com.
To post to this group, send email to firebase-angular@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-angular/80cd0de7-212d-477c-8960-8c30527cd462%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.