diff --git a/modules/angular2/src/core/compiler/pipeline/compile_element.js b/modules/angular2/src/core/compiler/pipeline/compile_element.js index 5ef49c036a..2ec4bb7bcf 100644 --- a/modules/angular2/src/core/compiler/pipeline/compile_element.js +++ b/modules/angular2/src/core/compiler/pipeline/compile_element.js @@ -134,7 +134,7 @@ export class CompileElement { // by the "value", or exported identifier. For example, ng-repeat sets a view local of "index". // When this occurs, a lookup keyed by "index" must occur to find if there is a var referencing // it. - MapWrapper.set(this.variableBindings, variableValue, variableName); + MapWrapper.set(this.variableBindings, variableValue, dashCaseToCamelCase(variableName)); } addEventBinding(eventName:string, expression:AST) { diff --git a/modules/angular2/test/core/compiler/integration_spec.js b/modules/angular2/test/core/compiler/integration_spec.js index 475d34c899..96cca00458 100644 --- a/modules/angular2/test/core/compiler/integration_spec.js +++ b/modules/angular2/test/core/compiler/integration_spec.js @@ -419,6 +419,23 @@ export function main() { }) })); + + it('should assign the element instance to a user-defined variable with camelCase using dash-case', inject([AsyncTestCompleter], (async) => { + tplResolver.setTemplate(MyComp, + new Template({inline: '

Hello

'})); + + compiler.compile(MyComp).then((pv) => { + createView(pv); + expect(view.locals).not.toBe(null); + + var value = view.locals.get('superAlice'); + expect(value).not.toBe(null); + expect(value.tagName.toLowerCase()).toEqual('div'); + + async.done(); + }) + })); + it('should provide binding configuration config to the component', inject([AsyncTestCompleter], (async) => { tplResolver.setTemplate(MyComp, new Template({ inline: '',