` element is a good choice for dynamic components because it doesn't render any additional output.
## Resolving components
Take a closer look at the methods in `ad-banner.component.ts`.
`AdBannerComponent` takes an array of `AdItem` objects as input, which ultimately comes from `AdService`.
`AdItem` objects specify the type of component to load and any data to bind to the component.`AdService` returns the actual ads making up the ad campaign.
Passing an array of components to `AdBannerComponent` allows for a dynamic list of ads without static elements in the template.
With its `getAds()` method, `AdBannerComponent` cycles through the array of `AdItems` and loads a new component every 3 seconds by calling `loadComponent()`.
The `loadComponent()` method is doing a lot of the heavy lifting here.
Take it step by step.
First, it picks an ad.
**How `loadComponent()` chooses an ad**
The `loadComponent()` method chooses an ad using some math.
First, it sets the `currentAdIndex` by taking whatever it currently is plus one, dividing that by the length of the `AdItem` array, and using the *remainder* as the new `currentAdIndex` value.
Then, it uses that value to select an `adItem` from the array.
Next, you're targeting the `viewContainerRef` that exists on this specific instance of the component.
How do you know it's this specific instance?
Because it's referring to `adHost`, and `adHost` is the directive you set up earlier to tell Angular where to insert dynamic components.
As you may recall, `AdDirective` injects `ViewContainerRef` into its constructor.
This is how the directive accesses the element that you want to use to host the dynamic component.
To add the component to the template, you call `createComponent()` on `ViewContainerRef`.
The `createComponent()` method returns a reference to the loaded component.
Use that reference to interact with the component by assigning to its properties or calling its methods.
## The `AdComponent` interface
In the ad banner, all components implement a common `AdComponent` interface to standardize the API for passing data to the components.
Here are two sample components and the `AdComponent` interface for reference:
## Final ad banner
The final ad banner looks like this:
See the .
@reviewed 2022-02-28