Answer the question
In order to leave comments, you need to log in
How to output data from controller to Angular js template?
Hello! I'm trying to make a SPA application on Django + Angular, set up a REST API, and as soon as I got to the public part I came across a problem: Angular refuses to load data from the controller into the template. I simplified the client application to the maximum, but this did not solve the problem:
app.js
var app = angular.module('uniApp', []);
app.controller('uniController', function ($scope) {
$scope.message = "some text";
});
<!DOCTYPE html>
<html ng-app="uniApp">
<head>
<meta charset="utf-8">
<title>UNI DIGIT</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.js"></script>
</head>
<body ng-controller="uniController">
<h1>{{ message }}</h1>
{% load staticfiles %}
<script src="{% static 'js/shared/angular-ui-router.min.js' %}"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/restangular/latest/restangular.js"></script>
<script type="text/javascript" src="{% static 'js/app.js' %}"></script>
</body>
</html>
main/
--static/
--js/
--app.js
--templates/
--main/
--index.html
Answer the question
In order to leave comments, you need to log in
The second option, along with the {% verbatim %} tag, is to override the AngularJS tags:
angular.module('app', []).config(function($interpolateProvider){
$interpolateProvider.startSymbol('{$');
$interpolateProvider.endSymbol('$}');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question