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.
答案 0 :(得分:1)
确保main.js包含在home.controller.js之前的HTML文件中...例如:
<script src="main.js"></script>
<script src="home.controller.js"></script>