How to Collaboration Another Controllers in App.js?

How to collaboration more than 1 controllers in app.js?
I think if we use ionic framework for big project. Of course we cannot create controller for each functions in 1 controller.js. It will make a lot of line. Example i have 2 functions like login and register. I create login-controller.js and register-controller.js. Login-controller.js i declare LoginCtrl,and register-controller.js i declare RegCtrl.
How to call two controller from different controllers file in app.js?:slight_smile:

Hi,

First of all it’s better to use separate files for each controller.
Regarding your question in app.js has a config and for each state you can define different controller.
Also you can use data-ng-controller in HTML

i’m trying to access my controller use ng-controller and it’s work. but if i comment angular.module who access my file controllers. my ng-controller it’s not work.

the question is, how to call two or more file controller.js in app.js, if we just call ng-controller in .html, it’s not work because the file controller.js not calling in app.js

  1. Uncomment the angular.module line.

  2. Create multiple files, one for each of your controllers.
    ** - angular.module('starter.menu-controllers').controller('MyCtrl01' ...
    ** - angular.module('starter.menu-controllers').controller('MyCtrl02' ...

  3. Import MyCtrl01 and MyCtrl02 on your index.html file and that’s it.

You can read more about controllers on angular site or you can check out ionic templates.

thx you,sir :slight_smile:
i will do that :slight_smile:
It’s work :smiley: