-
-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Injected variables in app.js don't load on initial screen #924
Comments
@LilSebastian5000 The behavior described probably comes from implicit binding context inheritance of composition engine. Can you check if |
@bigopon So, This can be reproduced in the skeleton-esnext-webpack repository after upgrading all existing aurelia dependencies to the latest, as well as webpack to version 3.12.0, and then adding the initialization of the constants as shown. I reproduced it in there after discovering it in my own team's application after upgrading, making sure it wasn't anything odd that was specific to our project :). It's easy enough to fix by just initializing it in the constructor of the first screen of the application, but I don't know if that is expected behavior? |
Inheriting binding context is desirable in some scenarios, such as composition with only view specified. There is no context being specified, so the newly compose view should use the parent binding context. There is some other scenarios where it's less desirable to inherit binding context, such as composition with both view and view model specified. Inheriting binding context in this case seems like a source of surprising and buggy behavior. This thread in templating resources https://github.com/aurelia/templating-resources/issues/222 is a good relevant discussion where you can get more information about this. We will probably address this in a major of |
I'm submitting a bug report
and
Please tell us about your environment:
Operating System:
Windows 10
Node Version:
v8.9.0
6.7.0
Aurelia CLI OR JSPM OR Webpack AND Version
webpack 3.12.0
Browser:
All
Language:
ESNext
Current behavior:
When injecting a variable into the constructor of app.js, it is not initialized on the first screen loaded in the application. When navigating to a subsequent screen, it becomes available for use in the tags of all viewModels.
Expected/desired behavior:
A variable initialized in the constructor of app.js should be available to all viewModels within tags without needing to inject them into each individual viewModel
This previously worked with aurelia-framework 1.1.5
Example Code based on skeleton-esnext-webpack, after updating dependencies in package.json
constants.js :
export const TEST_CONST = "Constant!";
app.js:
welcome.html:
The above constant does not print in welcome.html. However, if I put it inside users.html, it does print on that screen.
The text was updated successfully, but these errors were encountered: