app.controller('PostReq', function ($scope, $http) {
$scope.sendReq = function(name, color, age){
alert(name);
var intAge = parseInt(age);
$http({method: 'POST',
url: 'http://127.0.0.1:8000/api/cat/',
data: {name: name, color: color, age: intAge}
});
}});
<div layout-gt-sm="row" ng-controller="PostReq">
<md-input-container flex ng-model="catName">
<label>Name</label>
<input type="text"/>
</md-input-container>
<md-input-container flex ng-model="catColor">
<label>Color</label>
<input type="text"/>
</md-input-container>
<md-input-container flex ng-model="catAge">
<label>Age</label>
<input type="text"/>
</md-input-container>
<md-button class="md-raised md-warn" ng-click="sendReq(catName, catColor, catAge)">Create cat</md-button>
</div>
<div layout-gt-sm="row" ng-controller="PostReq as pr">
<md-input-container flex>
<label>Name</label>
<input type="text" ng-model="pr.catName"/>
</md-input-container>
<md-input-container flex >
<label>Color</label>
<input type="text" ng-model="pr.catColor"/>
</md-input-container>
<md-input-container flex >
<label>Age</label>
<input type="text" ng-model="pr.catAge"/>
</md-input-container>
<md-button class="md-raised md-warn" ng-click="pr.sendReq()">Create cat</md-button>
</div>
app.controller('PostReq', function ($scope, $http) {
$scope.sendReq = function() {
alert( $scope.catName);
var intAge = parseInt($scope.catAge);
$http({method: 'POST',
url: 'http://127.0.0.1:8000/api/cat/',
data: {name: $scope.catName, color: $scope.catColor, age: intAge}
});
}});