Asked variations on this question in a few places and read EVERYTHING on Google so I'm fairly certain this can't be done. But thought I would ask here one last time.
I want to append a GET $HTTP URL with a number of text input params.
For example
Date 1 textinput, day, month, year, +00 +'-' Date 2 textinput, day, month, year, +00 +'-'
= 1101201700-2101201700
This is the code I have so far and it works up to the point of adding whatever I type to the url, but as soon as I add another input field it fails saying the second input is undefined.
Any ideas? Want to keep it simple too ideally...
.controller("DateCtrl", function ($scope, $stateParams, dateService) {
$scope.events = dateService.getEvents($stateParams.date).then(function (events) {
$scope.events = events;
console.log("Date Controller1 says: Hello World - I also work");
});
factory....
.factory('dateService', function ($http) {
var events = [];
return {
getEvents: function (date, date2) {
var params = {
date:date,
date2:date2
}
return $http.get('url' + "&" + params.date + "-" + params.date2).then(function (response) {
events = response.data.events;
return response.data.events;
});
},
state...
.state('date', {
url: "/date/:date/:date2",
templateUrl: "templates/Date.html",
controller: "DateCtrl"
})
html...
<input type="text" placeholder="bla1" class="form-control" ng-model="date"/>
<input type="text" placeholder="bla1" class="form-control" ng-model="date2" />
<a ui-sref="date({date:date,date2:date2})">Go</a>
EDIT:
The url i want to call is an external one, not a page within the app.
This is close $http.get with 2 parameter in ionic framework (angularjs)
But I'm not sure what I'm doing with the controller since in my code I have to scope a param.
EDIT 2:
this now works except that date2 is showing as "undefined" in the url string...