This commit is contained in:
Le Deng
2017-03-06 13:00:07 -05:00
parent 29a2be1480
commit 4efefa3b72
3 changed files with 22 additions and 10 deletions

View File

@@ -3,7 +3,7 @@
<table id="bookListTable" class="table bordered highlight">
<thead>
<tr>
<th><input type="checkbox"/></th>
<th><input type="checkbox" (change)="updateSelected($event.target.checked)" /></th>
<th>Title</th>
<th>Author</th>
<th>Category</th>
@@ -17,7 +17,7 @@
<tr *ngFor="let book of bookList">
<td>
<input hidden="hidden" name="id" />
<input type="checkbox" [checked]="checked" (change)="updateRemoveBookList($event.target.checked, book)" />
<input type="checkbox" [checked]="allChecked" (change)="updateRemoveBookList($event.target.checked, book)" />
</td>
<td><a (click)="onSelect(book)" style="cursor: pointer">{{book.title}}</a></td>
<td>{{book.author}}</td>

View File

@@ -15,7 +15,9 @@ import {MdDialog, MdDialogRef} from '@angular/material';
export class BookListComponent implements OnInit {
private selectedBook : Book;
private checked:boolean;
private bookList: Book[];
private allChecked:boolean;
private removeBookList: Book[]=new Array();
constructor(private removeBookService:RemoveBookService, private getBookListService: GetBookListService, private router: Router, public dialog: MdDialog) {
@@ -48,7 +50,7 @@ export class BookListComponent implements OnInit {
err => {
console.log(err);
}
);
}
});
@@ -63,6 +65,16 @@ export class BookListComponent implements OnInit {
console.log(this.removeBookList);
}
updateSelected(checked:boolean){
if(checked) {
this.allChecked=true;
this.removeBookList=this.bookList;
} else {
this.allChecked=false;
this.removeBookList=[];
}
}
removeSelectedBooks() {
let dialogRef = this.dialog.open(DialogResultExampleDialog);
dialogRef.afterClosed().subscribe(result => {
@@ -73,7 +85,7 @@ export class BookListComponent implements OnInit {
},
err => {
}
);
};
location.reload();