简体   繁体   中英

How do I get a Scope for the first element of an array

I'm using AngularJS and Firebase and I have the below which is fine

var myTeam = Teams.child(thisTeam);   
var myFixtures = myTeam.child("fixtures").startAt(now).orderByChild("date"); 

$scope.team = $firebaseArray(myTeam);                 
$scope.fixtures = $firebaseArray(myFixtures);

Now I want to get the first fixture coming up and everything seems to point at being able to get it with

var myNextFixture = myFixtures.limitToFirst(1);  
and then  
$scope.fixtures = $firebaseArray(myFixtures); 

but that doesn't return anything, what am I missing?

The line var myNextFixture = myFixtures.limitToFirst(1);
sets myNextFixture to undefined, I don't understand why. Iwould have thought it would have set myNextFixture to the first fixture in myFixtures but it doesn't

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM