I have the following code, which was working fine until I deployed to a test server:
$scope.getUserList = function (userName) {
$http({
method: \
I wasn't able to use
tag since my application was created in a popup dynamically from another origion. I was considering the others option in this thread to use something like a basePath variable and use it in every $http, ng-src, templateUrl
etc
But that was a bit overhead, built a interceptor that change every url before a xhr is made
var app = angular.module("myApp", []);
app.config(["$httpProvider", function($httpProvider) {
$httpProvider.interceptors.push('middleware');
}]);
app.factory('middleware', function() {
return {
request: function(config) {
// need more controlling when there is more than 1 domain involved
config.url = "//example.com/api/" + config.url
return config;
}
};
});
app.controller("Ctrl", ["$http", function($http) {
$http.get("books"); // actually requestUrl = http://example.com/api/books
}])
And html aswell
But i do recommend to use
tag instead unless you are using window.popup()