1👍
✅
You can just generate a json representation of your data and assign it to a $scope variable in your controller.
Normally, you would fetch data from server using a REST API, through $http or $resource.
But if you want to avoid the extra calls, you can include the data in the first html, inside a <script>
tag. Output the data in JSON and assign it to a variable. Then use it wherever you need it.
Like this:
<html>
<body>
<div ng-repeat="item in items">{{item}}</div>
<script>
var data = { ... your data here, generated by Django when serving the HTML ... }
... in your controller...
$scope.items = data;
...
</script>
</body>
</html>
👤tato
Source:stackexchange.com