feat(ngFor): support a custom template

Part of #1989

Closes #4637
This commit is contained in:
Tobias Bosch
2015-10-09 12:04:10 -07:00
parent a8c34ae290
commit 6207b1af88
3 changed files with 32 additions and 2 deletions

View File

@ -39,7 +39,7 @@ import {isPresent, isBlank} from 'angular2/src/core/facade/lang';
* - `<li template="ng-for #item of items; #i = index">...</li>`
* - `<template ng-for #item [ng-for-of]="items" #i="index"><li>...</li></template>`
*/
@Directive({selector: '[ng-for][ng-for-of]', inputs: ['ngForOf']})
@Directive({selector: '[ng-for][ng-for-of]', inputs: ['ngForOf', 'ngForTemplate']})
export class NgFor implements DoCheck {
_ngForOf: any;
private _differ: IterableDiffer;
@ -54,6 +54,8 @@ export class NgFor implements DoCheck {
}
}
set ngForTemplate(value: TemplateRef) { this._templateRef = value; }
doCheck() {
if (isPresent(this._differ)) {
var changes = this._differ.diff(this._ngForOf);