I have a function in commonservice and i want to call the function by sending the type as argument from another controller and how can i do that,
commonservice :
function getCommonLookupData(type) {
var data = angular.fromJson(EmployeeRoles.getItem('lookupData'));
var arr = [];
if (data)
arr = data[type];
var arr1 = [];
if (arr) {
$.each(arr, function (index, val) {
arr1.push(val);
});
}
return arr;
}
}
contrlrm :
commonService.getCommonLookupData(EmployeeRoles);
and how can i get the arr of the function,can anyone help please.Thanks.
Rohìt Jíndal
27.3k16 gold badges80 silver badges133 bronze badges
asked Nov 16, 2016 at 15:05
MMR
3,03916 gold badges59 silver badges111 bronze badges
-
i cannot understand, do you want to call service function from different controllers ?Nadeem Khoury– Nadeem Khoury2016年11月16日 15:09:12 +00:00Commented Nov 16, 2016 at 15:09
1 Answer 1
You should inject the service in the controller like
app.controller('MyController',function($scope,myServiceName){
myServiceName.myServiceFunction();
});
answered Nov 16, 2016 at 15:10
Matheno
4,2026 gold badges40 silver badges54 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default