AngularJS ng-包括不起作用

时间:2014-12-21 22:15:27

标签: angularjs

我正在努力学习AngularJS。我有导航设置作为视图,我无法显示它。当我查看检查员时,我看到<!-- ngInclude: views/nav.html -->

的index.html

<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
    <meta charset="UTF-8">
    <title>The ToDo List</title>

    <script type="text/javascript" src="assets/js/lib/angular.min.js"></script>
    <script type="text/javascript" src="https://cdn.firebase.com/js/client/2.0.4/firebase.js"></script>
    <script type="text/javascript" src="https://cdn.firebase.com/libs/angularfire/0.9.0/angularfire.min.js"></script>
    <script type="text/javascript" src="assets/js/lib/angular-route.min.js"></script>
    <script type="text/javascript" src="assets/js/lib/angular-animate.min.js"></script>
    <script type="text/javascript" src="assets/js/app.js"></script>
    <script type="text/javascript" src="assets/js/controllers/activetaskscontoller.js"></script>


</head>
<body>
    <div class="navigation" ng-include="views/nav.html"></div>

这是我的app.js

var myApp = angular.module('myApp',
    ['ngRoute', 'firebase', 'appControllers']);

var appControllers = angular.module('appControllers', ['firebase']);

myApp.config(['$routeProvider',function($routeProvider) {
    $routeProvider.
        when('/active-tasks', {
            templareUrl: 'views/active-tasks.html',
            controller: 'ActiveTasksController',
        }).
        when('/completed-tasks', {
            templareUrl: 'views/completed-tasks.html',
            controller: 'CompletedTasksController',
        }).
        otherwise({
            redirectTo: '/active-tasks'
        });
}]);

1 个答案:

答案 0 :(得分:2)

ng-include期待字符串而不是路径。

尝试更改为:

<div class="navigation" ng-include="'views/nav.html'"></div>

您可以在此处详细了解该主题:AngularJS ng-include does not include view unless passed in $scope