How pass function to one controller to another?

HI i have the login controller in the controller.js it’s call 'AppCtrl’
in another controller ‘odlCtrl’ i have 2 http.get and two query to populate tables and show data in views,
i need to do this get at the login how can i pass function (and data…$rootScope?) between controller???

Thanks

$scope.nameOfYourFunction() or use $rootScope. It’s not a Ionic related question, it’s more about learning how to use AngularJS: https://angularjs.org/

ok thanks, but i have this error
TypeError: Object # has no method ‘chiamataUno’

‘chiamataUno’ is a function in another controller is an http get.

Once again, it’s not a Ionic related question, you need to learn the basic of AngularJS if you want to be comfortable with Ionic development. But to answer, I will suggest you to create a service for HTTP get/post in you app.js and then use it everywhere in your controller by doing getHttpService witch will returns you all the function like http get and post …

https://docs.angularjs.org/guide/services

3 Likes

Service is the way to go - keep your controllers lean.