Как получить значение ng-модели и разместить его в запросе на отправку контроллера?Как передать данные модели в почтовый запрос?
(function(angular) {
angular.module('urlShortener', ['ngAnimate'])
.controller('shortenerController', function($scope, $http){
$scope.customMode = false;
$scope.passData = function passData(){
$http.post('/add', {url: raw_url})
.success(function(data, status, headers, config) {
// this callback will be called asynchronously
// when the response is available
})
.error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
}
})
})(window.angular);
модель я использую:
<input ng-model="raw_url" type="text" placeholder="Paste your url here and we will shrink it!" class="form-control"/>
http://stackoverflow.com/questions/25411682/sending-data-in-angular-http-post PARAMS. –
ooh. Уведомление об изнашивании для успеха и ошибки https://docs.angularjs.org/api/ng/service/$http –
Оцените обратную связь, спасибо @SMeaden –