As discussed with @shahata and @petebacondarwin -
The problem I run into when writing lots of "component like" directives is the unnecessarily repeated configuration over and over again.
Registering controllers
It's redundant to have a separate controller declaration.
Registering controllers by name in a component based architecture is useful only for unit tests, where you'd want to use $controller to create an instance of the component's controller.
But registering it over and over again is redundant and can be done by the .component.
We should have one .comp.js file
If we use .component(), it should auto create a new controller, registered with the same component name (because it too must be unique).
So we should end up with one file where the .component() becomes a true "annotation like" thing, something like:
angular
.module('myModule')
.component('productList', {
controller: ProductListController,
templateUrl: 'product-list.comp.html'
})
function ProductListController(){
}
$controller('productList') // <-- should be an instance of ProductListController
I'd love to hear the cons for this approach
What do you think?