<div class="col-xs-8" ng-controller="Message">
<input type="hidden" name="_token"
value="{{csrf_token()}}">
<input type="hidden" ng-model="post_content.id"
class="form-control" value="1">
<textarea style="" ng-model="post_content.body"
placeholder="What's up?"></textarea><br>
<button ng-click="sendMessage(post_content)"
type="button" class="btn btn-default pull-right">Post</button>
</div>
thae above code when i post i get body model ony but i also to get id
here is my service
/**
* @ngdoc service
* @name StrimUp.message
* @description
* # message
*Author Muragijimana richard [email protected] and [email protected]
* Service in the httpApp.
*/
StrimUp.service('message', function message($http, $q, $rootScope) {
var message = this;
message.messageList = {};
message.getAllmessages = function(){
var defer = $q.defer();
$http.get($rootScope.endPoint + '/api/v1/message')
.success(function(res){
message.messageList = res;
defer.resolve(res);
})
.error(function(err, status){
defer.reject(err);
console.log(err);
})
return defer.promise;
}
message.sendMessage = function(post_content){
var defer = $q.defer();
$http.post($rootScope.endPoint + '/api/v1/message', post_content)
.success(function(res){
// console.log(res);
defer.resolve(res);
})
.error(function(err, status){
defer.reject(err);
})
return defer.promise;
}
message.deletemessage = function(id){
var defer = $q.defer();
$http.delete($rootScope.endPoint + '/deletemessage?messageId=' + id)
.success(function(res){
defer.resolve(res);
})
.error(function(err, status){
defer.reject(err);
})
return defer.promise;
}
return message;
});
and my controller is here
//Author Muragijimana Richard [email protected] [email protected]
StrimUp.controller('Message', function ($scope, message) {
$scope.init = function(){
$scope.getAll();
$scope.getAll();
}
$scope.post_content=this;
$scope.sendMessage = function(post_content){
message.sendMessage(post_content)
.then(function(res){
console.log(res);
}, function(err,status){
alert(status);
})
}
$scope.getAll = function(){
message.getAllmessages()
.then(function(res){
console.log(res);
$scope.message = message.messageList;
}, function(err){
// error
})
}
$scope.init();
});
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.