Comments (5)
Hi @bjornharvold, now with this repro steps I can have a better understanding about the issue, thank you for the provided information 👍
A similar topic was just discussed on #30: without defer
argument set to false
, setTitle
/setTag
methods simply subscribe to the NavigationEnd
event of the router. However, the observable above gets resolved after that event.
There's a subscription bound to the event, true. But it cannot be triggered just because NavigationEnd
event was emitted earlier. In this case, passing false
to defer
would execute the method immediately.
I'm thinking about possibilities without listening to NavigationEnd
event, however options are quite limited as NavigationEnd
is the only event whom we can retrieve urlAfterRedirects
property. We can't expect further functionality from the Angular team quite soon, as they're quite busy with the i18n stuff nowadays. However, if I can find an opportunity (there're possibilities, yes) to make it work with the desired way, be sure I'll get it done.
On the other hand, this issue reveals the fact that I need to document the behavior of defer
argument at the README - we can't expect people what's under hood at the first glance :)
So, I want to say my thanks again to @chrillewoodz @cybey and @bjornharvold for all your contributions.
from ngx-meta.
I can see the same issue in the deprecated ng2-metadata repo, but then when you start navigating again it's not updating anything. You need to go back to the top route and then go down the tree again and it will set whatever is defined in the router. There must be something wrong with the way you listen to router events.
from ngx-meta.
Hi @chrillewoodz, there was in issue #15 which prevented the default meta settings to be rendered on views without meta settings in its route definitions. That's why the deprecated ng2-metadata does not update anything. This behavior has been changed since the rc.4 release of @nglibs/meta. However, I see that we need to make improvisations.
I'll analyze this issue as well as #27 at a first available time, and then let you know about details. Meanwhile, any further inspections and issues reported are highly appreciated. Thank you.
from ngx-meta.
Hi @chrillewoodz, I've tested the issue documented above, using the latest version (@nglibs/meta
** v0.2.0-beta.4) on the @nglibs/example-app.
Without touching the default configuration (and also the meta
properties at the routes), I've modified the src/app/+about/about-banana.component.ts
as follows:
// angular
import { Component, OnInit } from '@angular/core';
// libs
import { MetaService } from '@nglibs/meta';
@Component({
template: `@nglibs about banana page<br/>
If your life sucks, start a new one in Banana Republic`
})
export class AboutBananaComponent implements OnInit {
constructor(private meta: MetaService) {
}
ngOnInit(): void {
this.meta.setTitle('Today the lucky person is: bjornharvold'); // as promised
}
}
Just after the initial navigation, the output (page title) was exactly:
showcasing the @nglibs utilities
Then, I clicked on the link Banana Republic
and navigated to /en/about/banana
. The output (page title) was exactly:
Today the lucky person is: bjornharvold | @nglibs example app
And finally, I pressed ctrl + F5
to reload the page (while F12 devtools was open, and browser cache was disabled), the output (page title) was exactly:
Today the lucky person is: bjornharvold | @nglibs example app
Again, based on the information you provided, I could not reproduce the issue - using the official showcase app @nglibs/example-app with the development environment mentioned below:
-
Angular version: 4.0.1
-
Browser: Chrome 56.0.2924.87 (64-bit)
-
Language: TypeScript 2.2.2
-
Node (for AoT issues):
node --version
= 6.10.10
Please make sure you're using the latest version of @nglibs/meta
** (v0.2.0-beta.4 at the moment). If there're any points you forgot to mention, or need more details feel free to ask again.
For now, I'm closing this issue.
Note: @bjornharvold, you see, I mentioned you too 😄
from ngx-meta.
Than you for the mention @fulls1z3 ;-) The problem I was having was not setting it directly but like this:
My current code:
this.activatedRoute.params
.map(params => params['id'])
.flatMap(id => this.hotelService.retrieveMetaData(id))
.subscribe((list: Array<MetaData>) => {
if (list && list.length > 0) {
list.forEach(md => {
switch (MetaDataType[md.type]) {
case MetaDataType.PAGE_TITLE:
this.metaService.setTitle(md.value, false, false);
break;
case MetaDataType.METADATA:
this.metaService.setTag(md.key, md.value, false);
break;
default:
console.log('do not know how to handle metadata type: ' + md.type);
}
});
}
},
error => {
return Observable.of<Array<MetaData>>();
},
() => {
}
);
Unless I add "false, false" the title doesn't update
from ngx-meta.
Related Issues (20)
- remove lodash peerDependency as it's not needed
- meta tags API call fails HOT 2
- meta doesn't get updated.
- upgrade to Angular 7 HOT 1
- Not fetching meta tags in web master HOT 1
- Make configurable callback exceptions HOT 2
- Default fallback on null instead of error (unless not defined in configuration)
- use with Angular i18n
- Set dynamic meta tags to use api call
- Allow use of ngx-meta in angular 8 project HOT 3
- Do you have any plan to apply for angular8? HOT 2
- Angular v9 support HOT 4
- The title does not display correctly in the browser history
- AOT Compiling Error - Function calls are not supported in decorators but 'MetaModule' was called HOT 7
- @ngx-meta/core Doesn't support Angular 11.X.X HOT 11
- Setting Tags from ts file.
- Linked-In Social Share issue HOT 1
- Uncaught TypeError: Cannot read property 'core' of undefined at ngx-meta-core.umd.js:4 HOT 1
- Angular 11/12 support HOT 6
- after ng update 12 HOT 2
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 ngx-meta.