Giter VIP home page Giter VIP logo

Comments (9)

meeroslav avatar meeroslav commented on August 20, 2024

@koodikindral Based on this log, it's you who should upgrade the angular version in you project. LocalizeRouter uses angular version 2.2.0 and ng2-translate 4.0.0.

As you can see in package.json:

  "peerDependencies": {
    "@angular/core": "^2.2.0",
    "@angular/http": "^2.2.0",
    "@angular/router": "^3.2.0",
    "rxjs": "^5.0.0-beta.12",
    "ng2-translate": "^4.0.0"
  }

Please let me know if it's conflicting with ng2-select that you're using. From what I see they have their version fixed to 2.0.0.

from localize-router.

meeroslav avatar meeroslav commented on August 20, 2024

@koodikindral Sometimes npm has issues with upgrading to latest versions so try one of these:

  • run npm install until all UNMET PEER DEPENDENCY errors are gone or
  • manually delete conflicting package folders in node_modules and run npm install once

from localize-router.

koodikindral avatar koodikindral commented on August 20, 2024

Thanks, got it working!
Another question regarding the implementation: Is it possible to get it working also with angular-seed: https://github.com/mgechev/angular-seed

It has somewhat different routing (each component has it's own routing module).

from localize-router.

meeroslav avatar meeroslav commented on August 20, 2024

Hi, it's possible as long as it's not lazy loaded (see #3).
Angular-seed uses so called child routes. It's used similarly as RouterModule in child modules:

LocalizeRouterModule.forChild(routes),
RouterModule.forChild(routes)

I will update documentation and example project as soon as possible.

from localize-router.

koodikindral avatar koodikindral commented on August 20, 2024

Seems better, but:

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './home.component';
import { LocalizeRouterModule, LocalizeParser } from 'localize-router/localize-router';

const routes: Routes = [
  { path: '', component: HomeComponent },
  { path: 'home', component: HomeComponent }
];

@NgModule({
  imports: [
    LocalizeRouterModule.forChild(routes),
    RouterModule.forChild(routes)
  ],
  exports: [LocalizeRouterModule, RouterModule]
})
export class HomeRoutingModule { }

->

zone.js?1479817675655:355 Unhandled Promise rejection: No provider for LocalizeParser! ; Zone: <root> ; Task: Promise.then ; Value: NoProviderError {_nativeError: Error: No provider for LocalizeParser!
    at NoProviderError.BaseError [as constructor] (http://loc…, keys: Array[1], injectors: Array[1]}

from localize-router.

meeroslav avatar meeroslav commented on August 20, 2024

Can you check in full log in which exact file does this happen or provide a plunkr example?
You can check https://github.com/meeroslav/localize-router-example for working example built with CLI.

What I can see from your code insert is that you've imported LocalizeParser but never used it. However, this can throw only tslint error (depending on lint config), not a runtime one.

This error looks like you tried to initialise child routes before the parent routes, but it's hard to say without looking at the full code.

from localize-router.

koodikindral avatar koodikindral commented on August 20, 2024

Thanks, much better now! One small problem though, when I open the app from root URL, home page won't be shown (added to the router-outlet), but when I open the page from http://localhost:5555/en for example, it's working as intended.

home-routing.module.ts

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './home.component';
import { LocalizeRouterModule } from 'localize-router/localize-router';

let routes: Routes = [
  { path: '', component: HomeComponent },
  { path: 'home', component: HomeComponent }
];

@NgModule({
  imports: [
    LocalizeRouterModule.forChild(routes),
    RouterModule.forChild(routes)
  ],
  exports: [LocalizeRouterModule, RouterModule]
})
export class HomeRoutingModule { }

app-routing-module.ts

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { LocalizeRouterModule } from 'localize-router/localize-router';

let routes: Routes = [{ path: '', redirectTo: 'home', pathMatch: 'full' }];

@NgModule({
  imports: [
    LocalizeRouterModule.forRoot(routes),
    RouterModule.forRoot(routes)
  ],
  exports: [LocalizeRouterModule, RouterModule]
})

export class AppRoutingModule { }

from localize-router.

koodikindral avatar koodikindral commented on August 20, 2024

Found the problem:

localize.changeLanguage('ee');

was called on app.component.ts's constructor :) Issue can be closed, thanks for the great package :)

from localize-router.

meeroslav avatar meeroslav commented on August 20, 2024

Glad to hear that. Thank you for your feedback!

from localize-router.

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.