0

I'm just starting to learn Angular so the issue I'm trying to figure out here might be a bit awkwardly formulated. I'll try my best and explain what I'm dealig with.

I have a main main.js module file where I have declared

angular.module('app', [
'ngRoute'

])

Now I have a separrate file for the controller as home.controller.js which contains

angular
.module('app')    
.controller('HomeController', ['$scope', function($scope) {
}]);

Is there any way to include the home.controller.js file withing the main.js file without having to put the script src in the html ? I have tried to import 'path/home.conntroller.js but I get this error

Module 'app' is not available! You either misspelled the module name or forgot to load it.

Appreciate the help.

1 Answer 1

2

Make sure main.js is included in your HTML file before home.controller.js ... for example:

<script src="main.js"></script>
<script src="home.controller.js"></script>

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.