javascript - Why is 'angular' not defined in a separate controller file? -


i declare angular module in 1 file, app.js this:

hookpointapp = {}; (function () {     "use strict";      var hookpointapp = angular.module("hookpointapp", ["ngresource"]);      hookpointapp.controller("rootcontroller", [         "$scope", "$http", function($scope, $http) {              $scope.getcurrentuser = function() {                 $http.post("/account/currentuser", {                     ....                     .then(function(data) {                             $scope.currentuser = angular.fromjson(data.data).id                         },                     ...             };             $scope.getcurrentuser();         }]); })(); 

this seems work, no errors reported when loads , runs function. then, in separate areas.js file, try declare controller module, so:

(function () {     'use strict';      angular.module("hookpointapp").controller('areascontroller', ["$scope", "$http", function ($scope, $http) {         ....     }; 

both files declare stuff in self executing functions, , scripts referenced so, @ bottom of body element:

@scripts.render("~/bundles/angular") <script src="~/scripts/app/app.js"></script> <script src="~/scripts/app/areascontroller.js"></script> 

where angular bundle contains 'official' angular modules, , other 2 bundled when can them working nicely. when execute line:

angular.module("hookpointapp").controller('areascontroller', ["$scope", "$http", function ($scope, $http) 

in areascontroller.js, error says

uncaught referenceerror: angular not defined 

yet angular bundle referenced, , expect, rendered before conventional script references. missing here, or doing stupidly?

just more info, angular bundle defined this:

bundles.add(new scriptbundle("~/bundles/angular").include(     "~/scripts/angular/angular.js",     "~/scripts/angular/angular-resource.js")); 


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -