Reusing Of Functions Which Is Defined Between Controllers
i would like to reuse the code defined between the controllers .controller('GenericController', ['$scope', '$controller', '$rootScope', '$dialogs', '$state', '$http', '$modal', '$q
Solution 1:
You can use the factory and create the object for the function to reuse it.
app.factory("sample",function(){
returnfunction() {
console.log("Hello");
};
})
else collating multiple common functions
app.factory("commonFunctions",function(){
commonFunction1(){
console.log("common func1")
}
commonFunction2(){
console.log("common func2")
}
return {
commonFunction1: commonFunction1,
commonFunction1: commonFunction2
};
})
Post a Comment for "Reusing Of Functions Which Is Defined Between Controllers"