Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 页面未以角度更新_Angularjs - Fatal编程技术网

Angularjs 页面未以角度更新

Angularjs 页面未以角度更新,angularjs,Angularjs,我正在使用angular(learning)创建一个测试项目网站,当我单击index.html页面上的test时,ng视图不会更新。在过去的两个小时里,我一直在网上寻找,并尝试了几种解决方案,但都没有效果。请帮助我做错事 index.html <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> <!-- A

我正在使用angular(learning)创建一个测试项目网站,当我单击index.html页面上的test时,ng视图不会更新。在过去的两个小时里,我一直在网上寻找,并尝试了几种解决方案,但都没有效果。请帮助我做错事

index.html

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
    <!-- Angular References -->
    <script src="Scripts/angular.min.js"></script>
    <script src="Scripts/jcs-auto-validate.min.js"></script>
    <script src="Scripts/angular-route.min.js"></script>
    <!-- Bootstrap Core CSS -->
    <script src="Scripts/jquery-1.9.1.min.js"></script>
    <script src="Scripts/bootstrap.min.js"></script>
    <link href="Content/bootstrap.min.css" rel="stylesheet" />
    <link href="Content/font-awesome.min.css" rel="stylesheet" />
    <!-- CSLMS App Angular References -->
    <script src="CSLMS_app/app.js"></script>
    <script src="CSLMS_app/Recipe_Values/ConstantValues.js"></script>
    <script src="CSLMS_app/Controllers/indexController.js"></script>
    <!-- Style Sheets -->
    <link href="Content/Site.css" rel="stylesheet" />
</head>
<body ng-app="CSLMS_app">
    <div ng-controller="indexController">
        <!-- Top Navigation -->
        <nav class="navbar navbar-dark bg-primary navbar-fixed-top" >
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">CS-LMS</a>
                </div>  <!-- /.navbar-header -->
                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="navbar-collapse collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li><a class="navbar-brand" href="#">Dashboard</a></li>
                        <li><a class="navbar-brand" href="#/Test">Test</a></li>
                    </ul>
                    <ul class="nav navbar-nav navbar-right">
                        <li class="dropdown">
                            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{user.username}}<span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a href="javascript:;">Links</a></li>
                                <li><a href="javascript:;">Edit Profile</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="javascript:;">Logout</a></li>
                            </ul>
                        </li>
                    </ul>
                </div><!-- /.navbar-collapse -->
            </div><!-- /.container-fluid -->
        </nav>

        <div ng-view></div>

    </div>
</body>
</html>
testController.js

'use strict';
app.controller('testController', ['$scope', '$route', function ($scope, $route) {
    $scope.message = "Test ";
}])
'use strict';
app.controller('indexController', ['$scope', function ($scope) {
    $scope.somedata = "That";
}]);
indexController.js

'use strict';
app.controller('testController', ['$scope', '$route', function ($scope, $route) {
    $scope.message = "Test ";
}])
'use strict';
app.controller('indexController', ['$scope', function ($scope) {
    $scope.somedata = "That";
}]);

这里只是一个猜测,但您可能希望移动此:

<script src="../CSLMS_app/Controllers/testController.js"></script>


退出Test.html并进入index.html的
元素。我怀疑这是一个问题。可能还有更多,但我至少会这么做。

您忘了加载testController的脚本。将此行添加到index.html:

<script src="CSLMS_app/Controllers/testController.js"></script>


console中是否有任何错误?可以使用$location.replace(“/test”)请检查console中是否有任何错误,但是您是否尝试从test.html中删除脚本源并将其放入index.html页面?如果要将jQuery与AngularJS一起使用,请在AngularJS之前引用它。此外,通常您希望在body元素结尾之前包含脚本。问题未修复yetHi Mistalis-上述脚本已加载到my Test.html文件中,但已将其删除并移动到index.html文件中。在控制台中仍然没有差异,也没有错误。任何想法!!!这会是一个问题吗?我正在运行VS2015和IIS Express。我了解到ng路线需要一个web服务器-?做到了,没有区别