F
F
Friend2016-10-13 19:29:07
Django
Friend, 2016-10-13 19:29:07

Why doesn't Django and AngularJS work together?

<!DOCTYPE html>
<html data-ng-app="App">
  <head>
    <link rel="stylesheet" href="style.css">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
    <script src="script.js"></script>
  </head>

  <body data-ng-controller="TestController">
        <table id="hotels">
            <tr>
                <th>Hotel Name</th>
                <th>Star Rating</th>
                <th>Hotel type</th>
                <th>Hotel Price</th>
            </tr>
            <tr data-ng-repeat="hotel in hotels | filter:search.type1 | filter:search.type2">
                <td>{{hotel.name}}</td>
                <td>{{hotel.star}}</td>
                <td>{{hotel.type}}</td>
                <td>{{hotel.price}}</td>
            </tr>
        </table>
        <br/>
        <h4>Filters</h4>
        <input type="checkbox" data-ng-model='search.type1' data-ng-true-value='luxury' data-ng-false-value='' /> Luxury &nbsp;&nbsp;&nbsp;
        <input type="checkbox" data-ng-model='search.type2' data-ng-true-value='double suite' data-ng-false-value='' /> Double suite
    </body>

</html>

This page works but does not load the js file for some reason, more precisely, it does not load the hotel data This
is an example that I took as a basis could it be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2016-10-13
@Tiran_94

<td>{{ '{{' }}hotel.name{{ '}}' }}</td>
<td>{{ '{{' }}hotel.star{{ '}}' }}</td>
<td>{{ '{{' }}hotel.type{{ '}}' }}</td>
<td>{{ '{{' }}hotel.price{{ '}}' }}</td>

Or
{% verbatim %}
<td>{{hotel.name}}</td>
<td>{{hotel.star}}</td>
<td>{{hotel.type}}</td>
<td>{{hotel.price}}</td>
{% endverbatim %}

It's better not to mix angular and djanga templates

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question