What could be the cause of error in dependency injection of ngRouteProvider
NOTE: $location has a dependency on ngRoute, thats why I need to inject it, while, I am not really using it, but $location only.
I embed the necessary js file into my php file by:
<script type="application/javascript" src="/library/angularjs/1.2.9/angular.min.js"></script>
<script type="application/javascript" src="/library/angularjs/1.2.9/angular-route.min.js"></script>
<script type="application/javascript" src="/library/angularjs/1.2.9/angular-route.min.js.map"></script>
<script src="/library/angular-ui/bootstrap/0.11.0/ui-bootstrap-tpls.js"></script>
I inject the modules into my module by:
var VPPContractsApp = angular.module('VPPContractsApp', ['ui.bootstrap','$location','$window'])
.controller('VPPContractsController', VPPContractsController);
function VPPContractsController($scope,$http,$modal,$location,$window){../})
Error message I received looks like:
Resource interpreted as Script but transferred with MIME type text/html: "/library/angularjs/1.2.9/angular-route.min.js.map". myfile.php:10
Uncaught SyntaxError: Unexpected token <
Inside the .map file when chrome inspector reported at the first line and begaining of the whole file (the actual file content is different where it is downloaded and reference from our own server's /library folder.)
I searched through everywhere can't find a proper solution.
What not gonna work: 1.Change text/javascript into application/javascript.
2.File Permission,I downloaded it directly from the official site:https://code.angularjs.org/
==========update 1
I keep receiving error in inspector
Uncaught Error: [$injector:modulerr] Failed to instantiate module VPPContractsApp due to:
Error: [$injector:modulerr] Failed to instantiate module $window due to:
Error: [$injector:nomod] Module '$window' is not available! You either misspelled the...<omitted>...1)
and seems it deal with how to put the injecting service ( except 'ui.bootstrap', but any other service ('$window','$resource','$location') all will call out error, and which ever will be called above error first if I switching around which to inject first. (i.e. if I place $resource before $window, the error will be about '$resource' not '$window'.
I wonder why they think they are not exist while I already loaded both angular-route and angular-resource?
angular.module('VPPContractsApp', ['ui.bootstrap','$location','$window']
$location
and $window
are no modules. They are services provided by angular by default. You don't need to include a module to use them. You can delete those two here.