Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.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
Javascript Can';获取标题应用下的ui路由器显示视图_Javascript_Angularjs_Angular Ui Router - Fatal编程技术网

Javascript Can';获取标题应用下的ui路由器显示视图

Javascript Can';获取标题应用下的ui路由器显示视图,javascript,angularjs,angular-ui-router,Javascript,Angularjs,Angular Ui Router,我刚刚开始使用ui路由器,无法在ui视图模板下显示视图 主模板如下所示 index.html <html ng-app="MyApp"> <head> <link href="stylesheets/style.css" rel="stylesheet"> </head> <body> <h4> This should be the header </h4> <div ui-view>&l

我刚刚开始使用ui路由器,无法在ui视图模板下显示视图

主模板如下所示

index.html

<html ng-app="MyApp">
<head>
  <link href="stylesheets/style.css" rel="stylesheet">
</head>
<body>
<h4>
    This should be the header
</h4>
<div ui-view></div>

<script src="vendor/angular.js"></script>
<script src="vendor/angular-ui-router.js"></script>
<script src="vendor/angular-route.js"></script>
<script src="vendor/angular-cookies.js"></script>
<script src="app.js"></script>
<script src="controllers/main.js"></script>

</body>
</html>
在“/”页面上,我只能看到一个标题,没有test.html文本。Console没有给出任何错误。 我在这里遗漏了什么?

检查这一点,这表明我们不应该忘记通过:
$urlRouterProvider设置默认路由。否则(“/”。因此,唯一的扩展是注入
$urlRouterProvider
,并配置启动时要做的事情(否则):

看看它在起作用

注意:另外,不要混合使用ui路由器和默认角度路由:

<script src="vendor/angular-ui-router.js"></script>
<!--<script src="vendor/angular-route.js"></script>-->


只需使用其中一个。您已经开始使用的
ui路由器
,将/应该足够好…

您能为该代码提供plunker吗?从第一眼看,似乎是正确的,我已经将我的nodejs目录中的所有内容复制到了一个plunker,它工作得很好,但在我的计算机上仍然无法工作。我会尝试从头开始。可能真的是一些非常简单的错误设置。。。但请不要放弃。Ui路由器真的是一个很棒的工具,我相信它以后会对你有很大帮助…;)
.config(function($stateProvider, $urlRouterProvider) {

    $urlRouterProvider.otherwise("/");

    $stateProvider
        .state('main', {
            url: '/',
            templateUrl: 'test.html',
            controller: 'MainCtrl'
          });
})
<script src="vendor/angular-ui-router.js"></script>
<!--<script src="vendor/angular-route.js"></script>-->