diff --git a/modules/core/src/compiler/view.js b/modules/core/src/compiler/view.js index 8f1c1d7728..2fb8163447 100644 --- a/modules/core/src/compiler/view.js +++ b/modules/core/src/compiler/view.js @@ -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); diff --git a/modules/core/test/compiler/view_spec.js b/modules/core/test/compiler/view_spec.js index 1a4e269bc5..fcceaebaaa 100644 --- a/modules/core/test/compiler/view_spec.js +++ b/modules/core/test/compiler/view_spec.js @@ -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', () => { diff --git a/modules/directives/src/ng_repeat.js b/modules/directives/src/ng_repeat.js index 3710e8d32a..d50fb25afe 100644 --- a/modules/directives/src/ng_repeat.js +++ b/modules/directives/src/ng_repeat.js @@ -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) { diff --git a/modules/directives/test/ng_repeat_spec.js b/modules/directives/test/ng_repeat_spec.js index 0e9a69509d..19ac6c521c 100644 --- a/modules/directives/test/ng_repeat_spec.js +++ b/modules/directives/test/ng_repeat_spec.js @@ -191,10 +191,9 @@ export function main() { }); }); -/* -TODO(rado): enable after compiler is fixed. + it('should display indices correctly', (done) => { - var INDEX_TEMPLATE = '
{{index.toString()}};
'; + var INDEX_TEMPLATE = '
{{i.toString()}}
'; 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(); }); }); -*/ + }); }