{{ 'MODAL.TITLE'" />

{{ 'MODAL.TITLE'" />

{{ 'MODAL.TITLE'"/>
DEVHIDE
  • Home (current)
  • About
  • Contact
  • Cookie
  • Home (current)
  • About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy
  • TOS
Login Or Sign up

ngx-translate not working in ng-bootstrap modal

2.4k Views Asked by Roger Ng At 30 August 2017 at 09:43 2025-12-18T05:41:35.887068

The ngx-translate's translate pipe does not work inside the ng-bootstrap's modal.

<div class="modal-header">
  <h3 class="modal-title">
    {{ 'MODAL.TITLE' | translate }}
  </h3>
</div>

<div class="modal-body">
</div>

<div class="modal-footer">
  <button class="btn btn-primary" type="button" (click)="activeModal.close('Close click')">
    <span class="fa fa-remove"></span> {{ 'BUTTON.CLOSE' | translate }}
  </button>
</div>

Sample screen

angular ng-bootstrap ngx-translate
Original Q&A
1

There are 1 best solutions below

5
Maxime Maxime On 30 August 2017 at 10:06

On the ngx-translate Readme, it's written :

NB: if you're still on Angular <4.3, please use Http from @angular/http with [email protected].

So what are the differences?

In Angular >= 4.3.x, instead of providing Http to the TranslateModule, you now need to provide HttpClient:

app.module.ts :

import {HttpClient, HttpClientModule} from "@angular/common/http"; //<-- before import {HttpModule, Http} from "@angular/http";
...
export function HttpLoaderFactory(httpClient: HttpClient) { //<-- before Http
    return new TranslateHttpLoader(httpClient, "i18n/", ".json");
}

@NgModule({
    imports: [
        ...
        HttpClientModule, //<-- before HttpModule
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: HttpLoaderFactory,
            deps: [HttpClient] //<-- before Http
          }
        })
    ],
    ...
})

I forked and fixed the Angular Demo (4.3.6) : https://plnkr.co/edit/1VZdWdQvat3lxaXYVZs3?p=preview

Related Questions in ANGULAR

  • Is it possible to use ES5 JavaScript with Angular 2 instead of TypeScript?
  • Module '"angular2/angular2"' has no exported member 'For'
  • import syntax in typescript creating another js file in visual studio
  • Separate ts file for imports
  • How to use an AngularJS 2 component multiple times in the same page?
  • injectables not working in angular 2.0 latest build 26
  • Does angular2 bootstrap have a way to dynamically target elements like it does in angular 1.x
  • Import {} from location is not found in VS Code using TypeScript and Angular 2
  • Angular 2/Typescript: require not found
  • ng-switch in Angular2
  • Angular 2 import issue: "Zone already exported on window the object!"
  • How to make FileReader work with Angular2?
  • Writing the most basic Unit test in Angular 2?
  • Angular2: Creating child components programmatically
  • AngularJS - TypeError: Cannot read property 'canonicalUrl' of undefined

Related Questions in NG-BOOTSTRAP

  • Why won't a [(ngModel)] of a radio group bind?
  • How to implement Bootstrap 4 for Angular 2 ngb-pagination
  • Angular2 Bootstrap Datepicker format date issue
  • How to pass parameteres to modal?
  • How to set the width of the dropdown in the typeahead module
  • dropdown toggle issue in navbar with ng-bootstrap (4) angular 2 (cli)
  • NgbDropdown doesn't stay open
  • How to customize the CSS for ng-bootstrap controls using Angular 2 / Bootstrap 4
  • Getting started directly on ng-bootstrap (without working on 1.5.8)
  • NgbModal error when trying to close
  • ng-bootstrap for Angular 2 datepicker does not popup the calendar
  • Issue with prepopulating ng-bootstrap's typeahead whilst relying on model driven forms
  • Angular 2 Alerts that work with Bootstrap 4, similar to Toastr
  • Display content on ngbModal when clicking on table row - Angular 2
  • stop closing the modal by clicking backdrop or outside the modal

Related Questions in NGX-TRANSLATE

  • ngx-translate not working in ng-bootstrap modal
  • Use ngx-translate in a multi-module Angular setup and child-libraries
  • Angular translate service, interpolate params in nested json
  • Cannot find module @angular/common/http Ionic 3 app
  • ngx-translate special chars issue
  • How to use instant with ngx-translate
  • Angular translator not working
  • ngx-translate with dynamic text on ts file
  • Angular 2+ dynamic translated page title using "TranslateService" & "Title"
  • ngx-translate custom loader doesn't find translations
  • ngx-translate .instant returns key instead of value
  • Organizing translation files in angular2
  • Translate variable value with ngx-translate
  • How to add translate for the breadcrumbs in coreui angular
  • How to localize data coming from the backend with ngx-translate

Trending Questions

  • UIImageView Frame Doesn't Reflect Constraints
  • Is it possible to use adb commands to click on a view by finding its ID?
  • How to create a new web character symbol recognizable by html/javascript?
  • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
  • Heap Gives Page Fault
  • Connect ffmpeg to Visual Studio 2008
  • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
  • How to avoid default initialization of objects in std::vector?
  • second argument of the command line arguments in a format other than char** argv or char* argv[]
  • How to improve efficiency of algorithm which generates next lexicographic permutation?
  • Navigating to the another actvity app getting crash in android
  • How to read the particular message format in android and store in sqlite database?
  • Resetting inventory status after order is cancelled
  • Efficiently compute powers of X in SSE/AVX
  • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

Popular # Hahtags

javascript python java c# php android html jquery c++ css ios sql mysql r reactjs

Popular Questions

  • How do I undo the most recent local commits in Git?
  • How can I remove a specific item from an array in JavaScript?
  • How do I delete a Git branch locally and remotely?
  • Find all files containing a specific text (string) on Linux?
  • How do I revert a Git repository to a previous commit?
  • How do I create an HTML button that acts like a link?
  • How do I check out a remote Git branch?
  • How do I force "git pull" to overwrite local files?
  • How do I list all files of a directory?
  • How to check whether a string contains a substring in JavaScript?
  • How do I redirect to another webpage?
  • How can I iterate over rows in a Pandas DataFrame?
  • How do I convert a String to an int in Java?
  • Does Python have a string 'contains' substring method?
  • How do I check if a string contains a specific word?
.

Copyright © 2021 Jogjafile Inc.

  • Disclaimer
  • Privacy
  • TOS
  • Homegardensmart
  • Math
  • Aftereffectstemplates