ng-options,ng-repeat在django模板中不起作用

时间:2017-09-18 11:58:49

标签: django-templates

我有django模板(html页面),如下所示

{% extends 'fabi/fabi_base.html' %}
{% block body %}
<body ng-app="django_fabi">
    {% load staticfiles %}
    <link rel="stylesheet" href="{% static 'fabi/datatables/jquery.dataTables.css' %}" />
    <script src="{% static 'fabi/jquery-3.2.1-min/jquery-3.2.1.min.js' %}"></script>
    <script src="{% static 'fabi/js/angular.min.js' %}"></script>
    <script src="{% static 'fabi/js/main.js' %}" type="text/javascript"></script>
    <div ng-controller="fabiCtrl" ng-model="selectedLevel">
        {% if fabs_logs %}
        {{ fabs_logs }}
        <p>Select Log File :</p> 
                <form ng-submit="submitAnswer()">
                <select ng-model="selectedLevel" ng-options="each_row.filename for each_row in fabs_logs">                  
                </select>
                <select ng-model="selectedLevel" placeholder="Select Log level" ng-options="level for level in levels">{{level}}</select>
                <button type="button" ng-click=submitLogs()>Submit</button>
                <br/>Selected File : {{ selectedLevel }}
                </form>
        {% endif %}
    </div>

</body>
{% endblock %}

fabs_logs的值低于我从views.py(django查询集)得到的值。

[{'levels': ['INFO'], 'filename': 'Fabs-Audit-slc09cxt.log'},
 {'levels': ['INFO'], 'filename': 'Event-slc09cxu.log'}, 
 {'levels': ['INFO', 'WARN', 'ERROR'], 'filename': 'Fabs-slc09cxt.log'}, 
 {'levels': ['INFO', 'WARN', 'ERROR'], 'filename': 'Fabs-slc09cxu.log'},
 {'levels': ['INFO'], 'filename': 'Fabs-Audit-slc09cxu.log'},
 {'levels': ['INFO', 'WARN', 'ERROR'], 'filename': 'Scheduler-slc09cxt.log'},
 {'levels': ['INFO'], 'filename': 'Event-slc09cxt.log'}, 
 {'levels': ['INFO', 'WARN', 'ERROR'], 'filename': 'Scheduler-slc09cxu.log'}]

在ng-options中,fabs_logs的值没有使用我从views.py获得的值进行插值

请问任何人如何在django模板中使用ng-options或ng-repeat

0 个答案:

没有答案