Skip to main content

angular - How to create function

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'Dashboard';

  getName(){
    return "Jenny"
  }
}
app.component.html

<h1>Hello, I am {{getName()}}!</h1>
More Angular tutorials