设置AngularUi应用程序

时间:2015-10-27 11:29:06

标签: javascript angularjs angular-ui-router angular-ui angular-ui-bootstrap

我尝试使用AngularUi启动单页应用程序,但我在制作基本示例时遇到问题。这是我的不同文件:

index.html:

<!doctype html>
<html lang="en" ng-app="studentDetailApp">
<head>
  <meta charset="UTF-8">
  <title>Student Details App</title>
  <link rel="stylesheet" href="../node_modules/angular-ui-bootstrap/ui-bootstrap-csp.css"/>
</head>

<body>
<div class="row-fluid" ng-controller="StudentController">
  <div class="span2">{{studentName}} </div>
  <div class="span4"><progress percent="studentMark"></progress></div>
</div>

<!--Required JS Files List :start -->
<script src="../node_modules/angular/angular.js"></script>
<script src="../node_modules/angular/angular-route.js"></script>
<script src="../node_modules/angular-ui-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="controllers/controllers.js"></script>
<script src="js/app.js"></script>
<!--Required JS Files List :end -->

</body>
</html>

controller.js:

'use strict';

/* Controllers Module for studentDetailApp application*/
var studentControllerModule = angular.module('studentDetailApp.controllers', ['ngRoute', 'ui.bootstrap']);

/*StudentController: controller for students*/
studentControllerModule.controller('StudentController', function($rootScope, $scope, $location, $routeParams) {

  $scope.studentName = "Sandeep Kumar Patel";
  $scope.studentMark = 75;

});

app.js:

'use strict';

angular.module('studentDetailApp', ['ngRoute', 'studentDetailApp.controllers']).

  config(['$routeProvider', function($routeProvider,StudentController) {

    $routeProvider.when('/', { controller: 'StudentController'});

    $routeProvider.otherwise({redirectTo: '/'});

  }]);

我有进度条,所以我猜AngularUI已正确初始化,但看起来我无法访问控制器数据。

我有这个错误:

  

错误:[$ injector:modulerr]无法实例化模块   studentDetailApp由于:

     

[$ injector:modulerr]无法实例化模块   studentDetailApp.controllers由于:

     

[$ injector:nomod]模块&#39; studentDetailApp.controllers&#39;不是   可以!您要么错误拼写了模块名称,要么忘记加载它。   如果注册模块,请确保将依赖项指定为   第二个论点。

     

http://errors.angularjs.org/1.4.7/ $注射器/ NOMOD?P0 = studentDetailApp.controllers

     

minErr /&LT; @ http://localhost:8080/node_modules/angular/angular.js:68:12

     

模块/&LT; @ http://localhost:8080/node_modules/angular/angular.js:1986:1

     

确保@ http://localhost:8080/node_modules/angular/angular.js:1910:38

     

模块@ http://localhost:8080/node_modules/angular/angular.js:1984:1

     

loadModules /&LT; @ http://localhost:8080/node_modules/angular/angular.js:4390:22

     

的forEach @ http://localhost:8080/node_modules/angular/angular.js:336:11

     

loadModules @ http://localhost:8080/node_modules/angular/angular.js:4374:5

     

loadModules /&LT; @ http://localhost:8

1 个答案:

答案 0 :(得分:1)

你是从头开始做这个项目吗?

我建议使用Yeoman。它是一个Angular项目生成器

https://github.com/yeoman/generator-angular