46 lines
1.0 KiB
TypeScript
Raw Normal View History

2015-12-15 00:44:06 -08:00
// #docregion
import { Component } from '@angular/core';
class Detail {
title: string;
text: string;
}
2015-12-15 00:44:06 -08:00
@Component({
selector: 'di-demo',
template: `
2015-12-15 12:34:29 -08:00
<h4>Tabs Demo</h4>
<ui-tabs>
2016-06-13 00:41:33 +02:00
<template uiPane title='Overview' active="true">
2015-12-15 12:34:29 -08:00
You have {{details.length}} details.
</template>
2016-06-13 00:41:33 +02:00
<template *ngFor="let detail of details" uiPane [title]="detail.title">
2015-12-15 12:34:29 -08:00
{{detail.text}} <br><br>
<button class="btn" (click)="removeDetail(detail)">Remove</button>
</template>
2016-06-13 00:41:33 +02:00
<template uiPane title='Summary'>
2015-12-15 12:34:29 -08:00
Next last ID is {{id}}.
</template>
</ui-tabs>
<hr>
<button class="btn" (click)="addDetail()">Add Detail</button>
2016-09-01 02:08:57 +01:00
`
2015-12-15 00:44:06 -08:00
})
2016-06-13 00:41:33 +02:00
export class DiDemoComponent {
2015-12-15 12:34:29 -08:00
details: Detail[] = [];
id: number = 0;
addDetail() {
this.id++;
this.details.push({
title: `Detail ${this.id}`,
text: `Some detail text for ${this.id}...`
});
}
2016-04-27 11:28:22 -07:00
removeDetail(detail: Detail) {
2015-12-15 12:34:29 -08:00
this.details = this.details.filter((d) => d !== detail);
}
2015-12-15 00:44:06 -08:00
}
2015-12-15 12:34:29 -08:00