ng-model . ,
<input ng-model="stickie_text" type="text" id="sticky_content" />
$scope.stickie_text 'formCtrl'. , : , .
:
<form ng-submit="submit()" ng-controller="formCtrl">
<input ng-model="stickie_text" type="text" id="sticky_content" />
<button type="submit" id="add_sticky" value="add a new stickie!">new sticky</button>
</form>
: stickie_text. - .
, ($scope.stickie_text).
$scope.submit:
$scope.submit = function() {
$http
.post('/api/stickies', {what: to, put: here})
.success(function(data){
})
.error(function(data){
console.log('Error: ' + data);
});
};
, , :
: - .
POST . , stickie ( , req.body.stickie ), , , : {stickie: $scope.stickie_text}. , stickie_text - , , , , var, . body parser .
, , :
app.post('/api/stickies',function(req,res){
var test = req.body.stickie;
db.run("INSERT INTO stickies (data) VALUES (?)", [ test ]);
});
, . - (res), nodejs (, res.write).
, :
$scope.submit = function() {
$http
.post('/api/stickies', {stickie: $scope.stickie_text})
.success(function(data){
})
.error(function(data){
console.log('Error: ' + data);
});
};
.
- @Kousha - ( formData ), , , , ), :
ng-model, . , :
ng-model="formData.stickie"
, , nodejs. , .
$scope.formData {stickie: whatEverIsInTheInputField}. , ng-model="formDta.foo" , $scope.formData {stickie: whatEverIsInTheInputField, foo: otherFieldValue}.
$scope.formData http-:
$scope.submit = function() {
$http
.post('/api/stickies', $scope.formData)
.success(function(data){
})
.error(function(data){
console.log('Error: ' + data);
});
};
formData $scope , stickie .