首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >角用户界面路由器出错了

角用户界面路由器出错了
EN

Stack Overflow用户
提问于 2016-07-22 18:33:09
回答 1查看 31关注 0票数 1

我已经试过多次了,但都没有用。这是我的装备:

角度: 1.5.7

角-用户界面-路由器: 0.3.1

这是我的档案:

代码语言:javascript
复制
/demo
  /node_modules
    (module files)
  -index.html
  -route1.html
  -route1.list.html
  -route2.html
  -route2.list.html

以下是文件内容:

index.html

代码语言:javascript
复制
<!doctype html>
<html data-ng-app="myapp">
  <head>
    <title>AngularJS ui-router Demo</title>
    <link href="<path to bootstrap css file>" rel="stylesheet" />
    <script src="<path to angular.min.js>"></script>
    <script src="<path to angular-ui-router.min.js>"></script>
    <script src="app.js"></script>
  </head>

  <body class="container">

    <div class="navbar">
      <div class="navbar-inner">
        <a class="brand" href="#">Quick Start</a>
        <ul class="nav">
          <li><a ui-sref="route1">Route 1</a></li>
          <li><a ui-sref="route2">Route 2</a></li>
        </ul>
      </div>
    </div>

    <div class="row">
      <div class="span12">
        <div class="well" ui-view></div>
      </div>
    </div>

    <!-- angular script -->
    <script>
      var myapp = angular.module('myapp', ['ui-router']);
      myapp.config(function($stateProvider, $urlRouterProvider) {
        $stateProvider
          .state('route1', {
            url: '/route',
            templateUrl: 'route1.html'
          })
          .state('route1.list', {
            url: '/list',
            templateUrl: 'route1.list.html',
            controller: function($scope) {
              $scope.items = ['A', 'List', 'of', 'Items'];
            }
          })

          .state('route2', {
            url: '/route2',
            templateUrl: 'route2.html'
          })
          .state('route2.list', {
            url: '/list',
            templateUrl: 'route2.list.html',
            controller: function($scope) {
              $scope.things = ['A', 'Set', 'of', 'Things'];
            }
          })
      })
    </script>

  </body>
</html>

route1.list.html,route1.html、 route2.html和route2.list.html都是简单的H1标签标题,带有P标记的虚拟文本,没有什么特别之处。

这个代码结构是从最初的AngularJS ui路由器示例中修改的.

代码似乎没有任何问题。如果有人注意到任何错误或绿丝虫,请通知。

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-22 18:39:09

问题在于:

代码语言:javascript
复制
var myapp = angular.module('myapp', ['ui-router']);

模块名为ui.router,因此将其更改为:

代码语言:javascript
复制
var myapp = angular.module('myapp', ['ui.router']);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38533202

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档