fix(NgRepeat): activate index
This commit is contained in:
parent
db0f0c462b
commit
52d88457c8
|
@ -71,8 +71,7 @@ export class View {
|
|||
setLocal(contextName: string, value) {
|
||||
if (!this.hydrated()) throw new BaseException('Cannot set locals on dehydrated view.');
|
||||
if (!MapWrapper.contains(this.proto.variableBindings, contextName)) {
|
||||
throw new BaseException(
|
||||
`Local binding ${contextName} not defined in the view template.`);
|
||||
return;
|
||||
}
|
||||
var templateName = MapWrapper.get(this.proto.variableBindings, contextName);
|
||||
this.context.set(templateName, value);
|
||||
|
|
|
@ -84,8 +84,8 @@ export function main() {
|
|||
expect(view.context.get('template-foo')).toBe('bar');
|
||||
});
|
||||
|
||||
it('should throw on undeclared locals', () => {
|
||||
expect(() => view.setLocal('setMePlease', 'bar')).toThrowError();
|
||||
it('should not throw on undeclared locals', () => {
|
||||
expect(() => view.setLocal('setMePlease', 'bar')).not.toThrow();
|
||||
});
|
||||
|
||||
it('when dehydrated should set locals to null', () => {
|
||||
|
|
|
@ -50,8 +50,7 @@ export class NgRepeat extends OnChange {
|
|||
|
||||
perViewChange(view, record) {
|
||||
view.setLocal('ng-repeat', record.item);
|
||||
// Uncomment when binding is ready.
|
||||
// view.setLocal('index', record.item);
|
||||
view.setLocal('index', record.currentIndex);
|
||||
}
|
||||
|
||||
static bulkRemove(tuples, viewPort) {
|
||||
|
|
|
@ -191,10 +191,9 @@ export function main() {
|
|||
});
|
||||
});
|
||||
|
||||
/*
|
||||
TODO(rado): enable after compiler is fixed.
|
||||
|
||||
it('should display indices correctly', (done) => {
|
||||
var INDEX_TEMPLATE = '<div><copy-me template="ng-repeat #item in items index #i">{{index.toString()}};</copy-me></div>';
|
||||
var INDEX_TEMPLATE = '<div><copy-me template="ng-repeat #item in items index #i">{{i.toString()}}</copy-me></div>';
|
||||
compileWithTemplate(INDEX_TEMPLATE).then((pv) => {
|
||||
createView(pv);
|
||||
component.items = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
@ -207,7 +206,7 @@ TODO(rado): enable after compiler is fixed.
|
|||
done();
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue