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.

v3: Access Line class from "@ng-bootstrap/ng-bootstrap/util/accessibility/live"

See original GitHub issue

For a number of reasons, I’ve subclassed NgbTypeahead. And to get the the constructor chain to work, I need to include the Live (@ng-bootstrap/ng-bootstrap/util/accessibility/live) class as a parameter.

With v2.x this worked fine, but I can’t get it to work with the new v3 packaging format.

Intellisense still knows about Live, but I can’t compile:

import {
  OnInit, Directive, ElementRef, ViewContainerRef, Renderer2, Injector, ComponentFactoryResolver, NgZone, forwardRef, Input
} from "@angular/core";
import { NgbTypeahead, NgbTypeaheadConfig, NgbTypeaheadWindow  } from "@ng-bootstrap/ng-bootstrap";
import { NG_VALUE_ACCESSOR } from "@angular/forms";
import { Observable } from "rxjs";

//THIS IS THIS PROBLEM
import { Live } from "@ng-bootstrap/ng-bootstrap/util/accessibility/live";
//THIS IS THE PROBLEM

export class MyTypeahead extends NgbTypeahead {
  constructor(private _elementRef2: ElementRef, _viewContainerRef: ViewContainerRef, _renderer: Renderer2,
    _injector: Injector, componentFactoryResolver: ComponentFactoryResolver, config: NgbTypeaheadConfig,
    ngZone: NgZone, live: Live) {
    super(_elementRef2, _viewContainerRef, _renderer, _injector, componentFactoryResolver, config, ngZone, live);
    }

  ...
}

Any ideas on how to access Live?

Angular: 6.1 ng-bootstrap: 3.0.0 Bootstrap: 4.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
pkozlowski-opensourcecommented, Aug 28, 2018

@dmostert I think that you are well past the point where you can simply extend the existing widget - you seem to have more specific needs which we don’t handle (yet) and this is OK.

As we are not ready to open up our widgets for extension I would suggest copy the code over to your project and maintain your own fork. Fully expect that this is not what you want to hear but writing widgets that can be sub-classed is entirely new challenge that we are not ready to accept at this point.

Closing as won’t fix.

6reactions
louislcommented, Aug 19, 2018

Just updated to Angular 6.1 and ng-bootstrap 3.0.0 and I’m having a similar problem accessing utils in a custom NgbDateParserFormatter, was working fine in 2.x:

ERROR in ./src/app/shared/formatters/ngb-uk-date-parser.formatter.ts
Module not found: Error: Can't resolve '@ng-bootstrap/ng-bootstrap/util/util'
import { NgbDateParserFormatter, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap'
import { Injectable } from '@angular/core'
import { isNumber, toInteger, padNumber } from '@ng-bootstrap/ng-bootstrap/util/util'

@Injectable()

export class NgbUkDateParserFormatter extends NgbDateParserFormatter {
  parse (value: string): NgbDateStruct {
    if (value) {
      const dateParts: Array<any> = value.trim().split('/')

      if (dateParts.length === 1 && isNumber(dateParts[0])) {
        return {
          day: toInteger(dateParts[0]),
          month: null,
          year: null
        }
      } else if (dateParts.length === 2 && isNumber(dateParts[0]) && isNumber(dateParts[1])) {
        return {
          day: toInteger(dateParts[0]),
          month: toInteger(dateParts[1]),
          year: null
        }
      } else if (dateParts.length === 3 && isNumber(dateParts[0]) && isNumber(dateParts[1]) && isNumber(dateParts[2])) {
        return {
          day: toInteger(dateParts[0]),
          month: toInteger(dateParts[1]),
          year: toInteger(dateParts[2])
        }
      }
    }

    return null
  }

  format (date: NgbDateStruct): string {
    return date ? `${isNumber(date.day) ? padNumber(date.day) : ''}/${isNumber(date.month) ? padNumber(date.month) : ''}/${date.year}` : ''
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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