Reputation: 2206
I've got an Angular controller
myApp.controller('DateController', function ($scope) {
$scope.date = {year: '2017', month: '08', day: '28'};
});
I've got a second controller for the same module:
myApp.controller('rateList', ['$scope', function ($scope, $http) {
$http.get('http://api.fixer.io/2000-01-03')
.success(function (data) {
$scope.rates = data.rates;
});
}]);
In my HTML I've got a form linked to that controller, and I successfully can change the values of $scope.date. What I need now is to take the values from $scope.date and have those loaded into the url in the http call. The example url I hardcoded was 2000-01-03. But I do not want to use these hardcoded values, I wish to use the values from $scope.date
Upvotes: 0
Views: 123
Reputation: 4533
This will do
$http.get('http://api.fixer.io/' + $scope.date.year + '-' + $scope.date.month + '-' + $scope.date.day)
or better
var dateString = $scope.date.year + '-' + $scope.date.month + '-' + $scope.date.day;
$http.get('http://api.fixer.io/' + dateString)
//your remaining code
Upvotes: 1