Exploring angular js for the first time and attempting to establish a connection between my controller and factory. Here is the controller:
var app = angular.module('app', ['ngRoute']);
app.controller('MainViewController',['MainViewFactory', function ($scope, MainViewFactory ,$location) {
//codes here
}]);
and this is the factory:
var app = angular.module('app');
app.factory('MainViewFactory' , function () {
var factory = {};
//factory codes here
return factory;
});
Encountering an injector error upon loading the page
Uncaught Error: [$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.
<!DOCTYPE html>
<html >
<head>
<meta charset="utf-8"/>
<title></title>
<link href="/public/css/bootstrap.min.css" rel="stylesheet">
<link href="/public/css/font-awesome.min.css" rel="stylesheet"/>
<link href="/public/css/style.css" rel="stylesheet"/>
<link href="/public/css/style-blue1.css" rel="stylesheet" id="style_color"/>
<link href="/public/css/jstree-themes/default/style.min.css" rel="stylesheet">
<link href="/public/lib/toaster/toaster.css" rel="stylesheet">
</head>
<body ng-app="app" ng-controller="MainViewController" >
<div id="navbar">
<span> </span>
</div>
<div id="container">
<div id="tools">
<button class="btn" ng-click="functions()"></button>
<button class="btn" ng-click="setting()"></button>
<button class="btn" ng-click="guide()"></button>
<button class="btn" ng-click="contactUs()"></button>
</div>
<div id="content" ng-view=""> </div>
</div>
<script type="text/javascript" src="/public/lib/angular/angular.js"></script>
<script type="text/javascript" src="/public/lib/angular/angular-route.min.js"></script>
<script type="text/javascript" src="/public/lib/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/public/app/factories/MainViewFactory.js"></script>
<script type="text/javascript" src="/public/app/controllers/MainViewController.js"></script>
</body>
</html>
Seeking assistance on resolving this issue!