Is there a way to retrieve the return value from a service method and set it into the scope for further processing in the template?
I've discovered that I cannot directly access the scope within services. While I could use Rootscope, I believe there might be a better approach.
Any suggestions on how I can easily transfer values from a service to the scope?
Thank you for any guidance provided.
Below is the code snippet:
/**
* Init autocomplete dropdown menu for project list
*/
this.getProjectListForAutocomplete = function (container, options) {
$("#autocompleteProjects").kendoAutoComplete({
dataSource : {
type: "json",
serverFiltering: true,
transport: {
read: function (options) {
console.log("List");
console.log(options.data);
ApiService.doHttpRequest(
"POST",
$rootScope.apiBaseUrl + "gpsaddress/search",
requestParams
)
.success(function (data, status, headers, config) {
break;
}
})
.error(function (data, status, headers, config) {
});
}
}
},
dataTextField: "city" ,
dataValueField: "address.city",
filter: "contains",
minLength: 1,
change : function (e) {
console.log("change");
//console.log(e);
},
select : function (e) {
console.log("select");
var dataItem = this.dataItem(e.item.index());
console.log(dataItem);
// Here i need set scope in controller
}
});
};