-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Upgrade to work on ng2 Final. #11
Comments
Hi, sorry for the delay! I'm aware that ng2-meta has issues on RC5 and beyond. I haven't had the time to keep up with the pace of changes in the ng2 ecosystem, but I'm getting around to it - I've started working on updating ng2-meta to support angular 2.0.0, and I hope to publish a new version in the middle of next week. Thanks for using ng2-meta |
Cool, we’re waiting for it, it great, hope you get it out soon! Thanks Ben From: Vinay Gopinath [mailto:notifications@github.com] Hi, sorry for the delay! I'm aware that ng2-meta has issues on RC5 and beyond. I haven't had the time to keep up with the pace of changes in the ng2 ecosystem, but I'm getting around to it - I've started working on updating ng2-meta to support angular 2.0.0, and I hope to publish a new version in the middle of next week. Thanks for using ng2-meta — |
+1 Good work here |
Hi, do you have a timeframe on when this is going to be complete? We are really looking forward to getting it into our latest build. The site we are building is www.tilecase.com. If you are interested in it we would love for you to follow us on LinkedIn at https://www.linkedin.com/company/4864276 |
The only problem I see is this
I hope it is not too hard to fix. |
It's not just the router/ The angular2-final-compatible code for ng2-meta is available (as a draft) on the feature/upgrade-to-angular2-final branch. You can install that via npm npm install --save vinaygopinath/ng2-meta#feature/upgrade-to-angular2-final Here's how it would be used (in an app generated by angular-cli): angular-cli.json "scripts": [
"../node_modules/ng2-meta/dist/index.js"
] typings.d.ts
app.module.ts import { MetaModule } from 'ng2-meta';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpModule,
MetaModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { } and then you can inject MetaService into your main component, as usual. Unfortunately, this throws the following error: Sorry that it's taken so long, and thanks for your help! |
@vinaygopinath I don't know how to fix problems but sometimes I find ways to avoid them. I commented out the whole route change subscription part that contains the firstChild problem and switched to programmatically set the title and meta for all my pages and it worked fine for me. Personally, I don't see the point of allowing them to write some json at the top of the component when it's the same to write couple JS lines in the ngOninit function right below. |
Hey there @vinaygopinath, |
@vinaygopinath Have a look at angular/angular#9662 (comment) which point to https://gist.github.com/alexbyk/0801373112b64bd171721c4b6b23e9e2 |
@vinaygopinath why are you using the forRoot here? because the MetaModule uses the RouterModule I suppose and you dont want to provide that again? I don't know if I understood the concept of forRoot correctly... Didn't have enough time yet to check for more but will do ASAP, sorry guys |
The idea behind using Also, I'd like to pass the configuration of |
Hey guys! This is how the app.module.ts would look like: import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { MetaConfig, MetaModule } from 'ng2-meta';
import { AppComponent } from './app.component';
import { FeatureComponent } from './feature.component';
let metaConfig = new MetaConfig({
//Append a title suffix such as a site name to all titles
//Defaults to false
useTitleSuffix: true,
defaults: {
title: 'Default title for pages without meta in their route',
titleSuffix: ' | Site Name',
'og:image': 'http://example.com/default-image.png',
'any other': 'arbitrary tag can be used'
}
});
@NgModule({
declarations: [
AppComponent,
FeatureComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot([
{ path: '', component: AppComponent,
data: {
meta: {
title: 'App List',
description: 'app ert5zuj gfdgh'
}
}
},
{ path: 'feature', component: FeatureComponent,
data: {
meta: {
title: 'Heroes List',
description: 'test'
}
}
},
{ path: '**', component: AppComponent }
]),
MetaModule.forRoot(metaConfig) // MetaModule.forRoot() would also be possible here
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { } and here goes the app.components.ts: import { Component } from '@angular/core';
import { MetaService } from 'ng2-meta';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app works!';
constructor(private metaService: MetaService) {}
} I just tested it quickly and it seems to work. Would be cool if some more people could test it and then maybe we can release ng2-meta for angular 2 final and beyond 👍 The
in the typings.d.ts shouldn't be necessary anymore. The Readme would have to be updated still etc. @vinaygopinath I never encountered your issue, I encountered some others though. I think maybe you just forgot to import your RouterModule in your app.module.ts which then could result in the error when trying to importing RouterModule in meta.module.ts? Not sure though... |
If some guys could confirm that the branch is working we can realease the version for angular 2 final. |
Trying to test. That is not working for me.
|
I am sorry, I forgot the feature/ in the branch name. Please try again with |
I can get it to work.... however, I am having problem with MetaConfig. I couldn't do:
I get this error:
Had to do it like this for now:
|
Seems like for some reason the MetaConfig interface is not exported correctly. I asked about why that is on Gitter Angular, and StackOverflow here http://stackoverflow.com/questions/39977025/cannot-find-name-of-exported-interface?noredirect=1#comment67233040_39977025 . @vinaygopinath Maybe you know more? Otherwise I would just suggest to create the MetaConfig as @bjornharvold suggests, at least the functionality and everything seems to work in Angular 2 Final for me. |
Hey folks, thanks a lot to everyone in this thread for helping out. @bergben I tested your PR briefly and it works great with the route configuration. @bjornharvold Since let metaConfig: MetaConfig = {
useTitleSuffix: true, // ok
useSomethingElse: true // not ok, useSomethingElse is not defined in type MetaConfig
}; I'll check the dynamic meta changes functionality tonight - If everything checks out, I should be able to make minor changes, update the README and publish the new version tomorrow :) Next up, server-side rendering/angular universal compatibility! :) P.S: npm has a shorthand for github dependencies - you can install a lib directly from any Github repo with |
Sounds like great progress. When will the readme doc be updated to show us the new usage instructions? |
README updated and new version published on npm! Thanks, everyone! |
thank you for this great work |
Will this component be upgraded to work on 2.0 Final?
It was great on RC4 but hasn't worked since.
The text was updated successfully, but these errors were encountered: