gpt4 book ai didi

javascript - 设置 AngularUi 应用程序

转载 作者:行者123 更新时间:2023-12-03 08:30:16 25 4
gpt4 key购买 nike

我正在尝试使用 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 已正确初始化,但看起来我无法访问 Controller 数据。

我遇到了这个错误:

Error: [$injector:modulerr] Failed to instantiate module studentDetailApp due to:

[$injector:modulerr] Failed to instantiate module studentDetailApp.controllers due to:

[$injector:nomod] Module 'studentDetailApp.controllers' 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.

http://errors.angularjs.org/1.4.7/$injector/nomod?p0=studentDetailApp.controllers

minErr/<@http://localhost:8080/node_modules/angular/angular.js:68:12

module/<@http://localhost:8080/node_modules/angular/angular.js:1986:1

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

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

loadModules/<@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/<@http://localhost:8

最佳答案

您是从头开始这个项目的吗?

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

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

关于javascript - 设置 AngularUi 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33366817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com