I am trying to bind "date.datefrom" and "date.dateto" from my datepicker to the end of my $http GET URL.
I can't seem to it, everything I try comes back as "undefined" but I've got my $scope in the controller, and the two sides work fine independent of each other - that is, the date picker updates the H3 tags correctly so the controller must be working, and if I hardcode in a date in the factory under "datefrom"/"dateto" it works. I just can't get them to bind together...
Code as follows
<ion-content class="item-input" ng-controller="DateCtrl">
<label class="item-input">
<span class="input-label">Date From</span>
<input type="date" ng-model="date.datefrom">
</label>
<h3>{{date.datefrom | date: "yyyyMMdd00"}}</h3>
<label class="item-input">
<span class="input-label">Date To</span>
<input type="date" ng-model="date.dateto">
</label>
<h3>{{date.dateto | date: "yyyyMMdd00"}}</h3>
<a href="#/date" class="button">GO</a>
Controllers
.controller("DateCtrl", function ($scope, $stateParams, dateService) {
$scope.date = {
datefrom: "Date From",
dateto: "Date To"
};
console.log("Date Controller1 says: Hello World - I also work");
})
.controller("DateDetailCtrl", function ($scope, $stateParams, dateService) {
$scope.events = dateService.getEvents($stateParams.date).then(function (events) {
$scope.events = events;
console.log("Date Controller says: Hello World - I also work");
});
})
Factory
.factory('dateService', function ($http) {
var events = [];
return {
getEvents: function (date) {
var url = 'http://api.URL.com&date=',
datefrom = 'date.datefrom',
dateto = 'date.datefrom',
key = "-";
return $http.get(url + datefrom + key + dateto).then(function (response) {
events = response.data.events;
return response.data.events;
});
},
getCEvent: function (index) {
return events.event[index];
}
}
})