Code Monkey home page Code Monkey logo

Comments (6)

arjenbrandenburgh avatar arjenbrandenburgh commented on May 19, 2024 1

You can solve it for now to use the function like this:

this.metadata.setTitle('Blog - ' + hello, false, false);

This disables the deferred part of the function

from ngx-meta.

fulls1z3 avatar fulls1z3 commented on May 19, 2024 1

Hi guys, I've been working on universal (aka platform-server) integration, and seems like it will be resulted soon. Then, I'll be able to release fixes for the listed bugs together with server-side rendering support.

from ngx-meta.

fulls1z3 avatar fulls1z3 commented on May 19, 2024 1

Hi @chrillewoodz, @cybey, @bjornharvold, 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/+home/home.component.ts as follows:

// angular
import { Component, OnInit } from '@angular/core';

// libs
import { MetaService } from '@nglibs/meta';

@Component({
  template: `@nglibs home page<br/>
  Enjoy it!<br/>`
})
export class HomeComponent implements OnInit {
  constructor(private meta: MetaService) {
  }

  ngOnInit(): void {
    const luckyPerson = 'chrillewoodz';
    this.meta.setTitle('Today, the lucky person is: ' + );
  }
}

The output (page title) was exactly:
Today the lucky person is: chrillewoodz | @nglibs example app

It worked when the title argument was a string concatenation.

Then I modified src/app/+home/home.component.ts further, using an observable:

// angular
import { Component, OnInit } from '@angular/core';

// libs
import { Observable } from 'rxjs/Observable';
import { MetaService } from '@nglibs/meta';

@Component({
  template: `@nglibs home page<br/>
  Enjoy it!<br/>`
})
export class HomeComponent implements OnInit {
  constructor(private meta: MetaService) {
  }

  private getTitle(): Observable<string> {
    return Observable.of('cybey');
  }

  ngOnInit(): void {
    this.getTitle().subscribe((res: string) => {
      this.meta.setTitle('Today the lucky person is: ' + res);
    });
  }
}

The output (page title) was exactly:
Today the lucky person is: cybey | @nglibs example app

It worked also when part of the title argument was supplied from an Observable.

So, I could not reproduce the issue based the information you provided - 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, I didn't forgot you. You'll be featuring as the lucky person shown on the page title, just at the further issue 😄

from ngx-meta.

chrillewoodz avatar chrillewoodz commented on May 19, 2024

I'm not sure if it's worth noting but it's inside a subscription call and it can run several times. When I do a test like this outside the subscription call it works as expected:

const hello: string = 'Hello world';

this.metadata.setTitle('Blog - ' + hello);

from ngx-meta.

fulls1z3 avatar fulls1z3 commented on May 19, 2024

Hi @chrillewoodz, thanks for your inspections.

I’ll look into this as soon as possible and then pingback on this issue my findings.

from ngx-meta.

bjornharvold avatar bjornharvold commented on May 19, 2024

+1

from ngx-meta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.