Adding a POST Call in Controller
1. Create a HelloWorldTask task type for the task application, and note the taskType ID.
2. In the defineScope block in controller, add the code in the try block as shown below.
defineScope: function(){
var _this=this;
....
_this.$scope.tasks= new Array();
// TAKING AN ARRAY OF TASK INSTANCES. THIS WILL BE DOUBLE BINDED TO THE UI
_this.$scope.createTaskInstance=function(){
//FUNCTION TO INVOKE FROM THE UI
var selectedAlias = "MWS1";
//SELECTED MWS SERVER ALIAS
var $scope=_this.$scope;
var requestData = {
//POST CALL REQUEST DATA
"taskTypeID":_this.$scope.config.params.taskTypeId,
// REPLACE THIS WITH THE TASK TYPE ID
"taskInfo":{
"name":"hello world1"
//YOU CAN GIVE ANY NAME TO THE TASK INSTANCE CREATED
}
};
_this.$scope.restClient.url("/rest/pub/opentask")
//Provide the server alias to connect to
.serverAlias(selectedAlias)
.method("POST")
//HTTP METHOD TO BE INVOKED
.requestData(requestData)
.remote(true)
.cors(true)
.scope($scope)
.gadgetConfig($scope.config)