I want to add simple angularjs code to django. For this I have taken the simple example: I have put the below code in my template:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
</script>
<div ng-app="myApp" ng-controller="myCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full name:{{firstName}}
</div>
</body>
</html>
My view.py is as follows:
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
# Create your views here.
def index(request):
template = loader.get_template('warlist/index.html')
return HttpResponse(template.render())
Now when I run it,it is taking the names in the text feild but It is not printing the full name. However same angularjs code is working fine without django.