I would like return value from service method into scope to using and processing in template.
But i found, that i cannot use scope in services. I can use Rootscope but i think, that it is not right approach.
How can I easily set value from service into scope?
Thanks for any advice.
Here is code:
/**
* 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
}
});
};