How to call ng-controller
method of angular.js after IBM worklight adapter success function?
I am using below function:
$("#viewCont").bind('click', function () {
var input = {
adapter: "sampleAdapters",
procedure: "GetViewList",
parameters: [empId]
};
WL.Client.invokeProcedure(input, {
onSuccess: function viewinAngular($scope, data) {
demoArray = ["Dynamic Group Header - 1", "Dynamic Group Body - 1", "Dynamic Group Header - 2", "Dynamic Group Body - 2"];
qtyArr = [];
for (var i = 0; i < demoArray.length; i++) {
var dataObject = new Object();
dataObject.dateLocalForamt = '123456';
dataObject.statusString = 'canclelled';
dataObject.reqstNumbaa = '123456789';
dataObject.Product_Desc = 'asdf';
dataObject.Quantity = 10;
qtyArr.push(dataObject);
}
$scope.data = qtyArr;
},
onFailure: authFailure,
timeout: 180000
});
}
function authFailure(response) {
WL.SimpleDialog.show("Alert", 'Check your network connectivity.', [{
text: "OK",
handler: function () {}
}]);
}
In your onSuccess callback function from your adapter invocation you can do the following:
var scope = angular.element(document.getElementById("exampleDivId")).scope();
scope.$apply(function(){
contact ={type:"phone",value: itemAFromAdapterResponse};
scope.settings.addContact(contact); //html will update based on ng-controller "setting's" function addContact
scope.settings.name = itemBFromAdapterResponse; //will update name in html as the response from your adapter invocation
})