0

I have such template in django:

<!DOCTYPE html > 
<html ng-app>
<head>
{% load staticfiles %}
<link rel="Stylesheet" type="text/css" href="{% static "style.css" %}" />
 <script src="ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.js"></script>
</head>
<body>

<p> red </p>

<input type="text" ng-model="name">
<h2> Hello {{ name }} </h2>
</body> 
</html>

But when i write some name in input, the name dont appear near "hello"

Mistalis
  • 17,793
  • 13
  • 73
  • 97
Alek H.
  • 119
  • 1
  • 2
  • 10

1 Answers1

1

It is because the {{ }} notation is also used by the template engine of Django. You have to use the tags openvariable and closevariable such as :

<h2> Hello {% templatetag openvariable %} name {% templatetag closevariable %} </h2>

So when it gets rendered, the actual {{ and }} are seen by angular.

The angular script may not be loaded with :

<script src="ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.js"></script>

try adding http://

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.js"></script>
Pierre Alex
  • 473
  • 2
  • 10