AngularJS uses a compile process to link directives and scopes. During compilation, it executes factory functions, template functions, compile functions, controllers, pre-link functions and post-link functions for each directive. This process recursively compiles child elements. The compiled output can then be linked with a scope during the linking phase to instantiate the directive.