In meiner angularJS App verwende ich symfony als Rest API.
Abhängig von meiner aktuellen URL verwende ich die $ http unter app_dev.php oder nicht. Ich erkannte dies mit dem folgenden Code:
app.run (function($rootScope, $location){
$rootScope.dev = "";
if ($location.absUrl().search("app_dev.php") > 0) {
$rootScope.dev = "app_dev.php/";
}
}
app.controller('OfferIndexCtrl', function($scope, $http, $location, $filter, $rootScope){
$http.get($rootScope.dev + 'stage/offer/get').success(function(json){
$scope.offerList = json.offerList;
});
}
Dies funktioniert gut. Aber die .run() läuft nach .config() und es ist nicht möglich, sie in den routeProvider zu integrieren.
Kann mir jemand helfen diese in meine routeProvider zu integrieren
app.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider){
$routeProvider.
when('/', {
templateUrl: 'stage/view/offer/index',
controller: 'OfferIndexCtrl'
}).
otherwise({
redirectTo: '/'
})
}
]);