2 Angular-系统指令、自定义指令ngIf
1 项目结构
2 myc01.component.ts
1 import { Component, OnInit } from '@angular/core'; 2 3 @Component({ 4 selector: 'app-myc01', 5 templateUrl: './myc01.component.html', 6 styleUrls: ['./myc01.component.css'] 7 }) 8 export class Myc01Component implements OnInit { 9 10 score = 50; 11 12 constructor() { } 13 14 ngOnInit(): void { 15 } 16 17 }myc01.component.ts
3 myc01.component.html
1myc01.component.htmlmyc01 works!
2成绩:{{score}}
3=90">优秀4=70">良好5=60&&score<70">及格6 7 8 9=60;else elseTemplate"> 10 及格 11 12 1314 不及格 15
4 效果