I am trying to further investigate the scope hierarchy in AngularJS. Recently, I've been paying close attention to the scope.$id numbering—and I've noticed that the value applied to a scope's $id
isn't applied in an incremental manner. For example:
<html ng-app="app">
<body ng-controller="appCtrl">
<!-- ngInclude: 'notifications.tpl.html' -->
<!-- ngInclude: 'otherTpl.tpl.html' -->
<div ng-include="someView.tpl.html">
<ui-view></ui-view>
</body>
</html>
This tree mirrors that of my DOM, where the html
element has a scope $id
of 1, body
has an $id
of 2, and the ng-include
has a scope $id
of 6, which doesn't seem to make much sense sequentially.
How are these id
numbers determined? Does it matter at all?
Thanks!