Skip to main content
added 361 characters in body
Source Link
Rahul Arora
  • 4.5k
  • 1
  • 19
  • 25

You can rather do:

angular.module("myApp")
.controller(...)

for both the controllers, rather than writing the variable here

Note: app.js should be loaded before any of the controllers for this to work.

This is one of the ways it can be done:

<html ng-app="myApp">
<head>
    <title></title>
</head>
<body>

    <script type="text/javascript" src="app.js"></script>
    <script type="text/javascript" src="controller1.js"></script>
    <script type="text/javascript" src="controller2.js"></script>
</body>
</html>

Apart from this you can also use some task runners like gulp OR grunt to do that automatically.

You can rather do:

angular.module("myApp")
.controller(...)

for both the controllers, rather than writing the variable here

Note: app.js should be loaded before any of the controllers for this to work.

This is one of the ways it can be done:

<html ng-app="myApp">
<head>
    <title></title>
</head>
<body>

    <script type="text/javascript" src="app.js"></script>
    <script type="text/javascript" src="controller1.js"></script>
    <script type="text/javascript" src="controller2.js"></script>
</body>
</html>

You can rather do:

angular.module("myApp")
.controller(...)

for both the controllers, rather than writing the variable here

Note: app.js should be loaded before any of the controllers for this to work.

This is one of the ways it can be done:

<html ng-app="myApp">
<head>
    <title></title>
</head>
<body>

    <script type="text/javascript" src="app.js"></script>
    <script type="text/javascript" src="controller1.js"></script>
    <script type="text/javascript" src="controller2.js"></script>
</body>
</html>

Apart from this you can also use some task runners like gulp OR grunt to do that automatically.

added 361 characters in body
Source Link
Rahul Arora
  • 4.5k
  • 1
  • 19
  • 25

You can rather do:

angular.module("myApp")
.controller(...)

for both the controllers, rather than writing the variable here

Note: app.js should be loaded before any of the controllers for this to work.

This is one of the ways it can be done:

<html ng-app="myApp">
<head>
    <title></title>
</head>
<body>

    <script type="text/javascript" src="app.js"></script>
    <script type="text/javascript" src="controller1.js"></script>
    <script type="text/javascript" src="controller2.js"></script>
</body>
</html>

You can rather do:

angular.module("myApp")
.controller(...)

for both the controllers, rather than writing the variable here

Note: app.js should be loaded before any of the controllers for this to work.

You can rather do:

angular.module("myApp")
.controller(...)

for both the controllers, rather than writing the variable here

Note: app.js should be loaded before any of the controllers for this to work.

This is one of the ways it can be done:

<html ng-app="myApp">
<head>
    <title></title>
</head>
<body>

    <script type="text/javascript" src="app.js"></script>
    <script type="text/javascript" src="controller1.js"></script>
    <script type="text/javascript" src="controller2.js"></script>
</body>
</html>
Source Link
Rahul Arora
  • 4.5k
  • 1
  • 19
  • 25

You can rather do:

angular.module("myApp")
.controller(...)

for both the controllers, rather than writing the variable here

Note: app.js should be loaded before any of the controllers for this to work.