Component

Components are the views of our Angular application in the sense that they control what, when, and how things should be displayed on the screen. They take the form of a simple class that defines the logic required by your views. Here's an example of a simple component:

export class FloydComponent implements OnInit {    private floydString:string = "";   private static startOfAlphabet = 97;    constructor() { }    ngOnInit() {   }    onClick(rows:number){          let currentLetter = FloydComponent.startOfAlphabet;     for (let i = 0; i < rows; i++) {       for (let j = 0; j < i; j++) {         this.floydString += String.fromCharCode(currentLetter) + " ";         currentLetter++;       }       this.floydString += "\n\r";     }   } }
Note that the component class has a suffix: ...

Get Angular Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.