The author of the book discussed the concept in the upcoming chapter:
Imagine compilation as the process of connecting HTML and controllers with the scope.
https://i.sstatic.net/7cZJn.png
The AngularJS compilation occurs in 2 stages:
1) the compilation phase and,
2) the linking phase.
https://i.sstatic.net/iT7UW.png
https://i.sstatic.net/M3ESH.png
After the HTML is loaded, AngularJS scans the DOM and compiles a list of all AngularJS directives; this is known as the compilation phase. Once the HTML is thoroughly examined, AngularJS moves into the linking phase, where it connects the AngularJS components to relevant scope instances.
Once the AngularJS template is connected to its corresponding controller through scope, the bindings become active and the two(view & controller) can interact.
https://i.sstatic.net/RB5DF.png
The compilation process happens automatically, and the linking between AngularJS templates and scope is seamless, but manual compilation of templates and scope together is also possible. Although it's not commonly needed, the function call effectively demonstrates the process.
$compile(element.contents())(scope);
In this method call, we are combining the contents of an HTML element with a scope object.