內嵌繫結 (Interpolation)


Template語法:

<element>{{變數名稱}}</element>

程式碼範例:

1.在Component.ts中加入變數title

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

@Component({
  selector: 'example-component',
  templateUrl: './example.component.html',
  styleUrls: ['./example.component.css']
})
export class ExampleComponent implements OnInit {

  title = '我的標題';

  constructor() { }

  ngOnInit() {
  }

}

2.在Template中使用內嵌繫結該變數

<h1>{{title}}</h1>

results matching ""

    No results matching ""