所以我有一个如下代码
base.html文件
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
{% block title %}
<title>Title</title>
{% endblock title %}
{% block basecss %}
<link href="{% static 'css/base.css' %}" type="text/css" rel="stylesheet" media="screen,projection">
{% endblock basecss %}
{% block css %}
{% endblock css %}
</head>
<body id="login-page">
{% block header %}
{% include 'manage_header.html' %}
{% endblock header %}
{% block navigation %}
{% include 'manage_navigation.html' %}
{% endblock navigation %}
{% block content %}
{% endblock content %}
{% block footer %}
{% endblock footer %}
</body>
{% block basejs %}
<script type = "text/javascript" src = "{% static 'js/jquery-1.11.2.min.js' %}"></script>
<script src = "{% static 'jquery/jquery-ui.js' %}"></script>
<script src = "{% static 'angular/underscore.js'%}"></script>
<script src = "{% static 'angular/angular.js' %}"></script>
<!-- <script src = "{% static 'angular/angular-route.js' %}"></script> -->
<script src = "{% static 'angular/angular-ui-router.js' %}"></script>
<script src = "{% static 'angular/restangular.js' %}"></script>
<script type = "text/javascript" src = "{% static 'js/materialize.js' %}"></script>
<script type = "text/javascript" src = "{% static 'js/perfect-scrollbar.min.js' %}"></script>
<!--plugins.js - Some Specific JS codes for Plugin Settings-->
<script type = "text/javascript" src = "{% static 'js/plugins.min.js' %}"></script>
<script type="text/javascript" src = "{% static 'js/custom-script.js' %}"></script>
{% endblock basejs %}
{% block js %}
{% endblock js %}
</html>
场景:1
{% block navigation %}
{% include 'manage_navigation.html' %}
{% endblock navigation %}
{% block content %}
<div ng-app="UserModule">
<div ui-view="">
</div>
</div>
{% endblock content %}
这很好,但是当我在下面做
时场景:2
<div ng-app="UserModule">
{% block navigation %}
{% include 'manage_navigation.html' %}
{% endblock navigation %}
{% block content %}
<div ui-view="">
</div>
{% endblock content %}
</div>
根本不起作用。
我想使用 scene:2 ,因为它包含导航栏,我想在点击导航栏中的菜单项时调用$stateProvider
中定义的状态。
解决方案按照接受的答案
{% block navigation %}
<div ng-app="UserModule">
{% include 'manage_navigation.html' %}
{% endblock navigation %}
{% block content %}
<div ui-view="">
</div>
</div>
{% endblock content %}
答案 0 :(得分:2)
您不能在子模板中拥有任何块外的内容。一切都需要在一个街区内。