Michael Mittelman Michael Mittelman - 10 days ago 6
AngularJS Question

Passing initial data from django to angular 2

I'm working on my first angular 2 app in an existing Django/Angular1 setup. We used to pass initial data in a django template to be consumed by angular in a tag like so:

<script type="text/javascript">
var id = '{{ id }}';
</script>


Then the angular app could utilize it by:

$scope.id = id;


How can I accomplish this same functionality with Angular2?

Answer

I think django has to do nothing here. According to angular 2

this.id = id
Comments