【发布时间】:2015-08-12 10:41:12
【问题描述】:
如何获取 ng-model 的值并将其放入控制器发布请求中?
(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"/>
【问题讨论】:
-
哦。成功与错误的弃用通知docs.angularjs.org/api/ng/service/$http
-
感谢您的反馈,感谢@SMeaden
标签: angularjs