angularjs - How can i call send and accept Json object from angular to backend on play frmaework? -
i have written front end in angularjs , end in scala on play frmaework. want send json object angular end calling method returns json object also. have written following code in angularjs, scala , on route file`
angular.js $scope.show=function(){ var url="localhost:9000" var urltext= { "url":$scope.url }; $http({ method:"get", url:url+"/geturl", params:{ data:urltext } }) .success(function(data){ $scope.url-title.push(data.title) $scope.url-description.push(data.description) $scope.url-img.push(data.img) }) } controllers.scala object application extends controller{ def returnurl(text:jsvalue):jsvalue ={ val str=(text \ "url").as[string] val obj=new urlpreview() obj.returndescription(str) val jsonobj:jsvalue=json.obj( "title" ->obj.returntitle(), "description"->obj.returndescription(), "img"->obj.returnimage() ) return jsonobj } } routes /geturl/{text} controllers.application.returnurl
` new in web development.so dont have enough idea. if have idea or doing mistake. please share ideas
if want send json should post or put instead of on angular side. in play side body parser comes play, route not contain parameter , in action method can use e.g. request.body.json.
Comments
Post a Comment