I'm trying to run XHR request on URL that controller obtain from template.
I get url like this
Angular code:
ManageControllers.controller('ManageCtrl', ['$scope', '$http',
function ManageCtrl($scope, $http) {
$scope.urls = {
edit : '',
get : ''
};
$http.post($scope.urls.get).success(function(data) {
$scope.recipe = data;
});
}
]);
HTML template:
<div ng-app="ManageApp">
<div ng-controller="ManageCtrl">
<input
ng-model="urls.save"
ng-init="
urls.save = '/save';
"
/>
<input
ng-model="urls.get"
ng-init="
urls.get = '/get';
"
/>
</div>
</div>
So far Angular reads value from trmplate. But it looks like $http runs before ng-init. So I don't know if it is better to run $http from some function with timeout or there is some proper, angular way of doing it.