Gorsky
Gorsky

Reputation: 13

Angular 2/4 - empty components (just view)

My question is:

What do you guys think of empty (?) components in Angular? Is that a mistake to create ones? Or is that a normal thing?

By empty I mean:

Components that have only basic structure and HTML in it.

Example:

Component.ts

    @Component({
        selector:...
        templateUrl: 'xxxx.html'
    })
    export class XXXXX {
    }

.html

    <p> Hi </p>

Upvotes: 0

Views: 1615

Answers (1)

Piotr Pliszko
Piotr Pliszko

Reputation: 676

Components are the most basic building block of an UI in an Angular application. It's not required to put complex logic into your component. For example, it can be a simple wrapper for another component.

Example of a very simple component:

@Component({selector: 'greet', template: 'Hello {{name}}!'})
class Greet {
  name: string = 'World';
}

More about components in Angular docs.

Upvotes: 1

Related Questions