I have successfully implemented http.jsonp for making cross-domain calls. Here is the configuration object I am using:
var config = {
params: {
action: "query",
prop: "revisions",
format: "json",
rvlimit: 50,
titles: 'obama',//works
// titles: val, //doesn't works
callback: "JSON_CALLBACK"
}
};
var url = "http://en.wikipedia.org/w/api.php?";
$http.jsonp(url, config).success(function(data) {
var pages = data.query.pages;
for (var pageid in pages)
{
$scope.revisions = pages[pageid].revisions;
break; // expect only one page
}
$scope.loaded = true;
});
While everything functions correctly with a static value of 'obama' for 'titles,' I am facing an issue when I try to dynamically set the value through an input box. I have created a jsfiddle reproducing the issue:
Any suggestions on how to resolve this?