framework
framework copied to clipboard
Using element selector in view model used in composition doesn't work
I'm submitting a bug report
- Library Version: 1.1.2
Please tell us about your environment:
-
Operating System: Windows 10 Pro
-
Node Version: 6.10.0
-
NPM Version: 3.10.10
-
Aurelia CLI OR JSPM OR Webpack AND Version webpack 2.2.1
-
Browser: all
-
Language: TypeScript 2.3
Current behavior: Using selector in a viewmodel to get an element marked with ref="" doesn't work when the view/viewmodel is used in a composition.
View: <ul ref="history">
ViewModel: attached() { console.log(this.hisory); }
returns undefined.
Expected/desired behavior: Referenced element should be available in the viewmodel.
Can you provide a full sample? I'm not quite following the specifics...
You misspelled history
in your viewmodel (it is spelled hisory
in the code you posted). If you've copied the code from your project, that might be the cause.
It is not actual code.
Because at the moment I don't have a sample I could provide, I try to describe the problem slightly better.
I create a view and a view-model and in the view I use ref="whatever"
on an element to be able to reference it from my view-model via this.whatever
. If I use this view/view-model pair in composition <compose view-model="${item.content}" model.bind="item.section"></compose>
inside another component, the reference is not created and this.whatever
returns undefined
.