I just read a post that says:
When Angular bootstraps your application, the HTML compiler traverses the DOM matching directives against the DOM elements.
What does "match... against" mean? How should we should use it?
This is almost more a web applications question than an English one, but since the word match here has a more general utility in other areas than web applications, I'll attempt a general answer. If you want something more detailed about HTML or HTML5, I suggest posting followups to webapps.stackexchange.com.
"DOM" is an acronym for "Document Object Model", about which you can read more here. The idea of the sentence is that the web language HTML 5 reads a list of elements in an HTML page, and reads a list of directives that pertain to each list. A very rough analogy is to think of making a number of purchases something by mail order from the same supplier. When you receive the order, you will take the packing list (comparable to the list of DOM objectives), and check off the items on the list with the items in the actual shipment to make sure they match. If the order is complete and accurate, the packing list should match the order, that is, there should be a one to one correspondence between the items on the list, and the items in the order.
For the more general question, about how to use "match ... against", it would be useful any time you have a list of some entity, and you need to check to see which of the items on the list are there, and which (if any) are missing. So in a gathering of people (like a meeting or a class) you would match the actual attendees against the list of those who are supposed to attend. Or, returning home from a shopping trip, where you forgot the list of things you intended to purchase, checking of the items you actually bought against those that you intended to buy. Or, with an automobile, where you have reached a certain number of miles, matching the maintenance you have actually done, with the suggested items in the owner's manual of the auto. One could also match two lists against each other.
In most cases, match ... against would be a parallel usage to "compare ... to".
What is being described is that "directives" are being matched against "elements". That is, each directive is relevant to none, one or more of the available elements, and it's applied to those elements as required.
The closest dictionary definition of against is Cambridge's touching, although it's hardly ideal:
next to and touching or being supported by (something):
Why don't we put the bed against the wall?
He loved the feel of her soft hair against his skin.
The rain beat against her face as she struggled through the wind.
The police officer had him up against the wall, both arms behind his back.
She leaned against the door.
in front of or compared to:
Paintings look best against a simple white wall.
A similar concept is illustrated by tally-sticks:
These are laid against (touching) each other, in order that the notches and marks in them can be compared and verified. Each notch in one stick needs to match a notch in the other. The notches are matched against each other. In the case of tally-sticks, they show payments made or due to the Exchequer: each notch is a particular amount of currency, so the notch for £100 needs to be matched with an identical notch in the other stick.
One idiomatic aspect of match against which is not present in match with is a concept of process. If notches are matched against each other, there is a process to verify that each notch in turn matches its counterpart. In the question's example, the verb traverse indicates a multi-step process which necessitates using against.
(Illustration of tally-sticks from David Astle)