Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>I would like to know how can i separate my big modules to several modules in several js files that communicate with each other.</p> </blockquote> <p>Sure you can use several modules and bind them like in following example:</p> <pre><code>var firstModule = angular.module('firstModule', []); var secondModule = angular.module('secondModule', ['firstModule']); </code></pre> <p>Now all services/directives created in <code>firstModule</code> are visible in <code>secondModule</code>.</p> <p>But before you create two modules you should ask yourself:</p> <p><strong>1. two modules</strong></p> <p>Multiple modules as I know is good way if your project has different sections with different dependencies.</p> <p>For example one module uses <code>ui.bootstrap</code> when other is empty, like:</p> <pre><code>var firstModule = angular.module('firstModule', []); var secondModule = angular.module('secondModule', ['ui.bootstrap','firstModule']); </code></pre> <p><strong>2. two controllers</strong></p> <p>The multiple controller approach is good to split business logic and make code clearer</p> <p><strong>3. one controller in two js files</strong></p> <p>You would want to implement this way (since we don't know your project goals)</p> <p>For example:</p> <p><strong>controllers.js</strong></p> <pre><code>var app = angular.module('myApp', []); app.controller('someCtrl', function($scope) { // call other js file: otherFile($scope); /*....*/ }); app.$inject = ['$scope']; </code></pre> <p><strong>someotherfile.js</strong></p> <pre><code>var otherFile = function($scope) { /*...*/ }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload