我正在製作一個包含50多個控制器的大型項目,有沒有辦法在每個控制器處於獨立視圖時獨立調用它?我不希望用戶一次加載所有的控制器。正如你可以看到下面所有的控制器將被稱爲無論我在我的網站上。Angularjs如何在視圖上導入控制器
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<base href="/">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css(app) styles/vendor.css -->
<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->
<!-- endbuild -->
<!-- build:css({.tmp,app}) styles/main.css -->
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
</head>
<body ng-app="nodeserverApp">
<!-- Add your site or application content here -->
<div class="container" ng-view=""></div>
enter code here
<!--[if lt IE 9]>
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/json3/lib/json3.min.js"></script>
<![endif]-->
<!-- build:js(app) scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/controllers/navbar.js"></script>
<script src="scripts/controllers/login.js"></script>
<script src="scripts/controllers/signup.js"></script>
<script src="scripts/controllers/settings.js"></script>
<script src="scripts/services/auth.js"></script>
<script src="scripts/services/session.js"></script>
<script src="scripts/services/user.js"></script>
<script src="scripts/directives/mongooseError.js"></script>
<!-- endbuild -->
</body>
</html>
當我嘗試script標籤移動到視圖,角不檢測控制器和發送錯誤。
我還沒有實現它,但這裏是一篇關於[AngularJS中的懶加載控制器]的文章(http://ify.io/lazy-loading-in-angularjs/) – Tom