in the below code, variables are defined using ng-init
directive, angular expression gives the access to those variables,
<body ng-app="">
<div ng-init="arr = [1, 2, 3, 4];obj={x:1}">
{{arr[0]}}
</div>
</body>
Using javascript code,
<body ng-app="">
<div ng-init="arr = [1, 2, 3, 4];obj={x:1}">
<script type="text/javascript">
//access arr[0] using div DOM object
</script>
</div>
</body>
I learnt that the data is directly binded to view(DOM).
To know the under-hood working of ng-init
directive, How do I access arr[0]
using div
DOM element?