question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

new npm package @nglibs/meta no longer update title programmatically

See original GitHub issue
[x] bug report => check the README and search github for a similar issue or PR before submitting
[ ] support request => check the README and search github for a similar issue or PR before submitting
[ ] feature request

Current behavior I recently upgraded the package from @nglibs/metadata to @nglibs/meta: the following issues have been noticed:

  • metaFactory defined and used in AppModule: only the title won’t update if set programmatically. Title remains the default set from the factory.
  • metaFactory not used in AppModule: title, description or other tags will not update programmatically.
  • meta info defined in the routes will work as expected. (not an issue)

Here is code to test second issue, to test the first issue I just uncomment the commented code: AppModule:


// export function metaFactory(): MetaLoader {
//     return new MetaStaticLoader({
//         pageTitlePositioning: PageTitlePositioning.PrependPageTitle,
//         pageTitleSeparator: ' - ',
//         applicationName: 'xxx xxxx some awesome company',
//         defaults: {
//             title: 'Default title',
//             description: 'Default description',
//             'og:image': '/images/common/the-logo.png',
//             'og:type': 'website',
//             'og:locale': 'en_CA',
//             'og:locale:alternate': 'en_US'
//         }
//     });
// }

@NgModule({
    imports: [
        ...,
        MetaModule.forRoot(),
        // MetaModule.forRoot({
        //     provide: MetaLoader,
        //     useFactory: (metaFactory)
        // }),
       ...,
    ],
    exports: [],
    declarations: [
        AppComponent
    ],
    bootstrap: [
        AppComponent
    ]
})

AppComponent:

export class AppComponent  {
    constructor(private readonly _meta: MetaService) { }
}

AboutComponent:

export class AboutComponent implements OnInit {
    constructor(private readonly _meta: MetaService) {
    }
    ngOnInit() {
        this._meta.setTitle('Page for test');                    // <-- no errors but title not set
        this._meta.setTag('description', 'Some description');    // <-- no errors but description tag not set
    }
}

Expected/desired behavior

No title and description set. Note: I did not have any problems with the previous version: @nglibs/metadata

Please tell us about your environment: Windows 7

  • Angular version: 2.0.X

The app is develop with Meteor.js and Angular2, see below npm dependencies

"dependencies": {
    "@angular/common": "2.4.3",
    "@angular/compiler": "2.4.3",
    "@angular/core": "2.4.3",
    "@angular/forms": "2.4.3",
    "@angular/http": "2.4.3",
    "@angular/platform-browser": "2.4.3",
    "@angular/platform-browser-dynamic": "2.4.3",
    "@angular/router": "3.4.3",
    "@nglibs/meta": "^0.2.0-rc.3",
    "@types/chai": "^3.4.35",
    "@types/mocha": "^2.2.38",
    "@types/node": "^0.0.2",
    "angular2-file-drop": "^0.0.5",
    "angular2-meteor": "^0.7.1",
    "angular2-meteor-accounts-ui": "^1.0.0",
    "angular2-meteor-polyfills": "^0.1.1",
    "angular2-meteor-tests-polyfills": "^0.0.2",
    "babel-runtime": "^6.22.0",
    "bcrypt": "^1.0.2",
    "bootstrap": "^4.0.0-alpha.6",
    "dragula": "^3.7.2",
    "gm": "^1.23.0",
    "lodash": "^4.17.4",
    "meteor-node-stubs": "^0.2.4",
    "meteor-rxjs": "^0.3.0",
    "ng2-auto-complete": "^0.10.9",
    "ng2-dragula": "^1.3.0",
    "prerender-node": "^2.7.0",
    "reflect-metadata": "^0.1.10",
    "rxjs": "^5.2.0",
    "spawn-sync": "^1.0.15",
    "systemjs": "^0.19.42",
    "tether": "^1.4.0",
    "toastr": "^2.1.2",
    "try-thread-sleep": "^1.0.2",
    "tslib": "^1.6.0",
    "zone.js": "^0.7.4"
  }

Tested on Chrome only

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
fulls1z3commented, Mar 3, 2017

Hi @bouchepat, finally I found some time to analyze this issue and made some remarks:

metaFactory not used in AppModule: title, description or other tags will not update programmatically.

When metaFactory is not used, title did not update programmatically. I’ve fixed this, and publish after when all tests are OK. However, description (and other tags) were updated. With the next update, I’ll double check this failure and it would be nice if we could share our results then.

metaFactory defined and used in AppModule: only the title won’t update if set programmatically. Title remains the default set from the factory.

Did not test this case totally, but will update soon.

0reactions
fulls1z3commented, Mar 16, 2017

Thanks @chrillewoodz, I wrote on #27 that I’ll analyze this asap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to update node modules programmatically - Stack Overflow
When I run this script, the modules get updated, but the new versions are not indicated in the package.json. When I run npm...
Read more >
Updating your published package version number - npm Docs
To change the version number in package.json , on the command line, in the package root directory, run the following command, replacing <update_type>...
Read more >
npm-outdated
Description. This command will check the registry to see if any (or, specific) installed packages are currently outdated.
Read more >
npm-programmatic
Use NPM commands programmatically. Latest version: 0.0.12, last published: 4 years ago. Start using npm-programmatic in your project by ...
Read more >
config | npm Docs
npmrc file by running npm login . access. Default: 'public' for new packages, existing packages it will not change the current level ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found