Question: I'm creating a lightning component named "scroll" and a controller file associated with it. Here's the opening tag of .cmp file:

```
<aura:component controller="scrollController" implements="force:appHostable,flexipage:availableForAllPageTypes,forceCommunity:availableForAllPageTypes" access="global" >

```

Every time I try to save the `.cmp` file, I get this error:

> 
> Failed to save scroll.cmp: Invalid definition for
>  null:scrollController: null: Source
> 
> 
> 

If I remove `controller="scrollController"` it will save no problem.

I stripped down the controller file to just a simple alert to weed out any possible JS issues:

```
({
     scroll: function() {

            alert('this works');

    },    
})

```

Answer: 
The controller attribute is used for an Apex class. You do not specify this attribute for any of the source files (e.g. scrollController.js in your bundle). You would use the controller attribute to access Apex code methods, such as performing DML, querying data, or making callouts.
In Lightning Aura Components, there are essentially two types of Controllers:

1. JavaScript Controller. The one which is part of the aura bundle. E.g., if you have a component named `myComponent.cmp`, then the JS controller for this will be `myComponentController.js`. You don't specify this controller anywhere in your component and the framework is aware of the corresponding controller JS for your component.
2. Apex controller. This is used when you need to communicate with the server to perform additional operations. This is when you use the `controller` attribute in your component (.cmp file) to specify the Apex controller for the component.

In your case, it seems you are referring to the JS file using the `controller` attribute, which is not required here. 

If you need more details on apex controllers and calling server side actions, you can refer to its [documentation here](https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_apex_create.htm).