Attempting to use angular js $get to fetch data. It can be done with a simple function like this:
<script>
$(document).ready(function() {
$.getJSON('{% url 'ajax-view' %}', function(data) {
alert(data['revenue']);
})
})
</script>
However, having trouble getting it to work in Angular since it's a new challenge for me.
<script>
var app = angular.module('plinc', []);
app.controller('MainCtrl', function($scope, $http) {
$http({
url: '{% url 'ajax-view' %}',
method: "GET"
}).then($scope.getdata = function(response) {
alert(data['revenue']);
$scope.data = response;
});
});
</script>
For the full Django template, you can visit: