Comments (17)
Please provide a runnable reproduction. There’s not enough information here to determine the issue but on the surface, the behavior seems likely correct as you’re using snapshot
, which is exactly that: a snapshot of the state. The value will only update if you read a new snapshot and that depends on whether the bindings execute again.
from angular.
Maybe this might help:
https://stackblitz.com/edit/stackblitz-starters-ki6sdw?file=src%2Fmain.ts
Parent
protected ngOnInit(): void {
// assign project ID
this.activatedRoute.params.
pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((params) => {
this.projectID = params['id'];
console.log(this.projectID)
});
// if project in store doesn't match, get it
if (this.projectStore.project()._id != this.projectID) {
// do something
}
}
Child
ngOnInit(){
console.log(this.router.url)
this.activatedRoute.params.
pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((params) => {
console.log(params['id'])
});
}
last link in child, via params is wrong, hence all the child routerLinks in the template, are relative to the wrong url path.
The address bar shows the correct url
from angular.
The reproduction doesn’t have provideRouter
with any routes. Is that intended?
from angular.
Sorry,
This ought to work, but I'm getting a compilation error that it cannot find App_Routes:
https://stackblitz.com/edit/stackblitz-starters-ki6sdw?file=src%2Fmain.ts
from angular.
Your main.ts
should be outside the src
directory.
from angular.
Removed that app router bug, I put the variable inside main.ts... not sure if it works for you
https://stackblitz.com/edit/stackblitz-starters-ki6sdw?file=src%2Fmain.ts
(for me the window says ...loading)
In JetBrains, I still get this:
Parent
protected ngOnInit(): void {
// assign project ID
this.activatedRoute.params.
pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((params) => {
this.projectID = params['id'];
console.log(this.projectID)
});
// if project in store doesn't match, get it
if (this.projectStore.project()._id != this.projectID) {
// do something
}
}
Child
ngOnInit(){
console.log(this.router.url)
this.activatedRoute.params.
pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((params) => {
console.log(params['id'])
});
}
from angular.
Check the console for the errors. The selector on the bootstrapped component doesn't exist in the index.html.
from angular.
Strange, my consol is clean, but the window to the right says '...Loading'
from angular.
Check the browser's console, it's not a build error but a runtime error.
from angular.
Looks fine on StackBlitz... maybe I need to upgrade Angular or JetBrains:
from angular.
Only difference that I can tell is that I lazy load the project routes in app_routes, in Jet Brains:
export const APP_ROUTES: Routes = [
{
path: 'projects',
title: 'App | Projects',
loadChildren: () => import('../1. project-module/projects/projects.routes').then((m) => m.PROJECTS_ROUTES),
},
{
path: 'projects/:id',
title: 'App | Project Details',
loadChildren: () => import('../1. project-module/project-container/project-container.routes').then((m) => m.PROJECT_ROUTES),
},
from angular.
Ahh.. but the child in my code does sit inside a defer block, inside the parent! Maybe that is it
Yes, I've confirmed. It is because of the defer block! This is the same / similar bug to another error I had last month.
I'll upgrade Angular to see if the issue resolves...
from angular.
Resolved in Angular 17.3.8
Issue was a bug in Angular 17...
(ahh, after all that de-bugging!)
from angular.
It was indeed fixed by #54864
from angular.
Crumbs, but now I get the same re-cursion error as last time, after doing npm install @angular/core... : (
"dependencies": {
"@angular/animations": "^17.3.2",
"@angular/cdk": "^17.3.1",
"@angular/common": "^17.3.2",
"@angular/compiler": "^17.3.2",
"@angular/core": "^17.3.8",
"@angular/forms": "^17.3.2",
"@angular/material": "^17.3.1",
"@angular/material-experimental": "^17.3.5",
"@angular/material-moment-adapter": "^17.3.5",
"@angular/platform-browser": "^17.3.2",
"@angular/platform-browser-dynamic": "^17.3.2",
"@angular/router": "^17.3.2",
"@material/web": "^1.4.1",
"@ngrx/operators": "^17.2.0",
"@ngrx/signals": "^17.2.0",
"lodash": "^4.17.21",
"material-components-web": "^14.0.0",
"moment": "^2.30.1",
"rfdc": "^1.3.1",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.2"
},
from angular.
Closing as this issue has become more of a support request and requires a reproduction in order to debug. (Reproductions can be GitHub repositories). Please open a new issue with a reproduction if you are able to create one.
from angular.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
from angular.
Related Issues (20)
- Ivy compiling error: Cannot destructure property 'pos' of 'file.referencedFiles[index]' as it is undefined. HOT 4
- Using `ComponentFixtureAutoDetect` in a zoneful test triggers CD too early (causing errors like NG0950) HOT 2
- Canonical: Components cannot be fully initialized before `ApplicationRef.tick` with ZoneJS and `TestBed.createComponent`
- style binding syntax stopped working in newer Angular versions HOT 6
- https://angular.dev/guide/pipes page not found HOT 1
- Unnecessary white spaces inside tag (at the beginning and in the end of text) HOT 3
- docs: `window.ng globals` is rendered incorrectly in the API Reference navigation list
- viewChild.required() is lying about its type - please remove this API while it's still in developer preview! HOT 5
- Add recommended tools/extensions as part of the getting started tutorial
- ERROR TypeError: Cannot read properties of undefined (reading 'c') HOT 1
- Signal input migration throws "No inputs were found in config file" when run in CLI projects
- Wrong content children order when using ngTemplateOutlet to render HOT 3
- Link to license is not working
- Docs: `@NgModule` tags in the source code should be used to hint at the Module declaring the class
- Wrong usage of HostBinding in example code HOT 6
- Angular project creation failed in npm 9.0.7 HOT 5
- Feature Request: Support for @defer Blocks with Inline Styles and Third-Party Scripts HOT 2
- `provideClientHydration` is doing magic with the rendered HTML HOT 4
- Incorrect documentation for `setPosition` method in `AnimationPlayer` interface HOT 2
- Date pipe calculation with timezone offset is wrong at Daylight Saving Time transition HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular.