javascript - AngularJS ng-view 不加载模板文件内容

标签 javascript html angularjs angularjs-module angularjs-config

我正在尝试设置一个演示 Angular 应用程序,但出于某种原因,我的部分 (partials/test.html) 内容没有加载到布局文件中。这是 index.html:

<!DOCTYPE html>
<html lang="en" ng-app="btq">
   <head>
      <meta charset="utf-8" />
      <title>NgView Test</title>
   </head>
   <body>
      <p>Some stuff on the page.</p>
      <div ng-view></div>
      <script src="js/angular.js"></script>
      <script src="js/app.js"></script>
   </body>
</html>

AngularJS 是 1.0.7 版。 app.js 包含以下内容:

'use strict';

// Declare app level module which depends on filters, and services
angular.module('btq', []).
  config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/dashbaord', {templateUrl: 'partials/test.html', controller: 'DashboardCtrl'});
    $routeProvider.otherwise({redirectTo: '/dashboard'});
  }]);

/* Controllers */

angular.module('btq.controllers', []).
  controller('DashboardCtrl', [function() {

  }]);

我显然遗漏了一些简单的东西。任何帮助,将不胜感激!

最佳答案

可能是因为“打字错误”。你在这里写的是“dashbaord”而不是“dashboard”:

$routeProvider.when('/dashbaord' , ...

关于javascript - AngularJS ng-view 不加载模板文件内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17008020/

相关文章:

javascript - 使第 n-child div 中的图像成为点击链接

javascript - 从其他组件中的 map 传递 div 数据

javascript - 给定 X、Y、宽度和高度变量,如何在 Google App 脚本中查找形状的开始值和结束值?

html - 为什么我的弹出式取消按钮不可点击?

javascript - 使用 jQuery html() 函数将 PHP 变量传递给 div

javascript - Angular Directive(指令)隔离范围 : scope function won't execute

javascript - 如何将标签本地保存到设备?

JAVASCRIPT 如何在选择选项中获得多个值

html - 最大宽度和自动换行在 IE8 中不起作用

angularjs - Spring 微服务、无状态 session 、 Angular 和静态文件服务