I've hit a roadblock with this issue. Despite reading extensively about it, I can't seem to solve it. The problem arises when I declare my <script>
app.js before utilizing ng-app, leading to the following error:
Failed to instantiate module app due to:
[$injector:nomod] Module 'app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
This particular error only surfaces on Firefox.
Html :
<html lang="en-US">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<link rel="stylesheet" type ="text/css" href="css\bootstrap.min.css"/>
<link rel="stylesheet" type ="text/css" href="css\component.css"/>
<link rel="stylesheet" type ="text/css" href="css\app.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
<script type="text/javascript" src="js\modernizr.custom.js"></script>
<script type="text/javascript" src="js\ui-bootstrap-tpls-1.2.4.min.js"></script>
<script src="js\app.js"></script>
</head>
<body ng-app="app">>
<div class="top row">
<top-header></top-header>
<home-carousel></home-carousel>
</div>
</body>
</html>
js :
app.directive('topHeader', function() {
return {
restrict: 'E',
templateUrl: 'topHeader.html',
controller: function ($scope, $window) {
name = $window.location.pathname;
n = name.lastIndexOf("/");
name = name.substring(n + 1);
if (name === "index.html" || name === "")
$scope.current = '1';
else if (name === "resume.html")
$scope.current = '2';
else if (name === "projects.html")
$scope.current = '3';
}
};
});
app.directive('homeCarousel', function() {
return {
restrict: 'E',
templateUrl: 'homeCarousel.html',
controller: function ($scope)
{
$scope.myInterval = 5000;
$scope.noWrapSlides = false;
$scope.active = 0;
var slides = $scope.slides = [];
var currIndex = 0;
$scope.addSlide = function()
{
slides.push(
{
image: "image" + currIndex+ ".jpg",
id: currIndex++
});
};
for (var i = 0; i < 3; i++)
{
$scope.addSlide();
}
}
};
});