Giter Site home page Giter Site logo

Bug: Unable to change month and first click isn't registered when directive uses formControlName for Angular 15 about angular-datepicker HOT 4 OPEN

mwgriffiths88 avatar mwgriffiths88 commented on June 2, 2024
Bug: Unable to change month and first click isn't registered when directive uses formControlName for Angular 15

from angular-datepicker.

Comments (4)

vlio20 avatar vlio20 commented on June 2, 2024 1

I hope to have a look into it this weekend

from angular-datepicker.

HimanshuAgrahari07 avatar HimanshuAgrahari07 commented on June 2, 2024

I was checking this issue and i found something strange

When we first declare the value and return it from the same getter, it works

https://stackblitz.com/edit/angular-ivy-cbn2yw?file=src/app/hello.component.ts

Although i could not able to debug the reason behind this

from angular-datepicker.

HimanshuAgrahari07 avatar HimanshuAgrahari07 commented on June 2, 2024

When we return it from a function (It doesn't work as expected)

@Component({
  selector: 'hello',
  template: `
    <form [formGroup]="form">
      <input
        formControlName="datetime"
        [dpDayPicker]="config()"
        mode="daytime"
        theme="dp-material dp-main" />
    </form>`,
  styles: [`h1 { font-family: Lato; }`],
})
export class HelloComponent implements OnInit {
  form!: FormGroup;

  config(): IDatePickerDirectiveConfig {
    return {
      minutesInterval: 5,
      firstDayOfWeek: 'mo',
      format: 'DD-MM-YYYY H:mm',
    };;
  }

  ngOnInit(): void {
    this.form = new FormGroup({
      datetime: new FormControl(null),
    });
  }
}

When we have an object created already, and we just have to return (it works)

  private _config: IDatePickerDirectiveConfig = {
    minutesInterval: 5,
    firstDayOfWeek: 'mo',
    format: 'DD-MM-YYYY H:mm',
  };

  config(): IDatePickerDirectiveConfig {
    return this._config;
  }

from angular-datepicker.

HimanshuAgrahari07 avatar HimanshuAgrahari07 commented on June 2, 2024

I assume there is some kind of horse condition here [creating object ref and then return vs just returning the ref for already created object]

from angular-datepicker.

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.