FirebaseExtended / angularfire

AngularJS bindings for Firebase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How i get random Value from specific field from the database Question

Kitsune9Tails opened this issue · comments

I get this and work , i need get random startup_url to show

angular.module('StartupApp')
.controller('ChatCtrl', function ($scope, Ref, $firebaseArray, $timeout) {
// synchronize a read-only, synchronized array of startups, limit to most recent 10
$scope.startups = $firebaseArray(Ref.child('startups').limitToLast(10));
// display any errors
$scope.startups.$loaded().catch(alert);

// provide a method for adding a message
$scope.addStartup = function(newStartup) {
  if( newStartup ) {
    // push a message to the end of the array
    $scope.startups.$add({ startup_url: newStartup.url, twitter: newStartup.twitter, email: newStartup.mail, 
      contact_name: newStartup.contac, location: newStartup.location, logo_img: newStartup.logo, 
      category: newStartup.category })
      // display any errors
      .catch(alert);
  }
};
function alert(msg) {
  $scope.err = msg;
  $timeout(function() {
    $scope.err = null;
  }, 5000);
}
$scope.randomQuote = $scope.startups[Math.floor(Math.random()*$scope.startups.length)];

});

This is a usage question, which is better suited for Stack Overflow or the Firebase Google Group. Can you please re-post on one of those forums and paste the link here? Please also remember to include version information to help us resolve your issue.