I've posted a precedent issue with my Background image in DIV. It's work successfully with current date. But when I want to adapt Background Image with time entered by user in database with model "starthourid", it's don't work (It display "night") ! But the database is OK, I can display "nameid" in HTML and "startdateid" with "starthourid".
This is a part of my code :
HTML :
<div ng-repeat="event in events">
<div class="card" >
<div class="sunrise item item-divider" ng-class="time">
<h2 class="text stable"> {{ event.nameid }} </h2>
<h3 class="text stable" id="header-date">
<i class="icon ion-clock"></i> Le {{ event.startdateid | date : "d MMM" }} à {{ event.starthourid | date : "HH:mm" }}</p>
</div>
<div class="row">
<div class="col">
<h3><i class="icon ion-ios-location"></i> location</h3></div>
<div class="col"><h3><i class="icon ion-ios-people">
</i> people</h3></div>
</div>
<button class="button button-stable" id="positive-btn-price" disabled>price</button>
<img class="imgProfilEventPositive" src="{{ event.userid.facebook.cachedUserProfile.picture.data.url }}">
<div class="item item-divider" id="footerEventNotepositive"><p> <i class="fa fa-star"></i> note </p> </div>
</div>
</div>
</div></div>
Controller JS :
$scope.events = Event.all;
$scope.event = {'nameid': ''};
var h = new Date(event.starthourid).getHours(event.starthourid);
if (h>=6 && h<11) {
$scope.time="sunrise";
} else if (h>=11 && h<18) {
$scope.time="day";
} else if (h>=18 && h<21) {
$scope.time="sunset";
} else {
$scope.time="night";
}
$scope.create = function() {
$state.go('tabstep1');
};
$scope.close = function() {
$state.go('tabdash');
};
Services JS :
myApp.factory("Event", ["$firebaseArray", "$firebaseObject", function($firebaseArray, $firebaseObject) {
var eventRef = new Firebase('https://myApp.firebaseio.com/Events/');
var userRef = new Firebase('https://myApp.firebaseio.com/Users/');
var events = $firebaseArray(eventRef);
var Event = {
all: events,
get: function (event){
var eventInfo = $firebaseObject(eventRef);
event.startdateid = new Date(event.startdateid);
event.starthourid = new Date(event.starthourid);
return $firebaseObject(eventRef.child('Events').child(userid));
}
,
add: function (event){
var eventInfo = $firebaseArray(eventRef, userRef);
event.userid = userRef.getAuth();
event.startdateid = new Date(event.startdateid).toJSON();
event.starthourid = new Date(event.starthourid).toJSON();
return eventInfo.$add(event);
}
}
return Event;
}]);