繁体   English   中英

AngularJS-简单的部分不加载

[英]AngularJS - simple partial not loading

我无法使用angular 1.3加载我的部分代码。 我已经看到了常见的错误,例如不加载angular-route.js或在我的应用模块中指定“ ngRoute”。 我在控制台中看不到任何错误。 我查看了所有“部分未加载”帖子,它们似乎不适用于此处。 知道这里发生了什么吗? 谢谢!

的index.html

<html ng-app="App">
<head></head>
<body ng-controller="MainController">

<div ng-view=""></div>

<script src="scripts/angular/angular.js"></script>
<script src="scripts/angular/angular-route.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/controllers.js"></script>
<body>
</html>

app.js

(function() {
var app = angular.module('App', ['ngRoute']);

app.config(function($routeProvider) {
    $routeProvider
        .when('/', 
            {
                controller: 'MainController',
                templateURL: './partials/test.html'
            })
        .otherwise({ redirectTo: '/' });
    });

}());

controllers.js

(function() {
    var MainController = function ($scope) {
        $scope.model = {
            message: 'Aaarrrgh!'
        };
    };
    MainController.$inject = ['$scope'];
    angular.module('App').controller('MainController',  MainController);    
}());

test.html(我的部分)

<h1>{{model.message}}</h1>

我应该在哪里看到我的内容,我看到一个html注释:

<!-- ngView: -->

templateURL重命名为templateUrl

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM