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.

Binding `undefined` should not change default values

See original GitHub issue

When binding e.g. aspectRatio to the image cropper, an “undefined” gets treaded as false rather than the default value (true). This is because every settings get set hard in a loop (https://github.com/Mawi137/ngx-image-cropper/blob/9f26c8a1b06e6aa4dcdcd79c3faa519f3e406500/projects/ngx-image-cropper/src/lib/interfaces/cropper.settings.ts#L45).

Would you like (me) to make undefined set the default value and only null set the value? Or does this feel like a breaking change to you? Right now I must repeat your default values in my control reflecting your properties. I cannot use [maintainAspectRatio]="maintainAspectRatio" without setting it to true initially.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
angelakicommented, Jul 26, 2022

Sorry I don’t find the time for it right now - I’ve got it on my backlog 😉

0reactions
stale[bot]commented, Oct 28, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Input() takes undefined after providing default value
The default value means when you are not passing any value, then angular puts the default value. But here you are passing undefined...
Read more >
Input() default value is not honored #42913 - angular ... - GitHub
Once you pass a value to the input, it should use it as the new value, null and undefined are also considered as...
Read more >
this - JavaScript | MDN
It can't be set by assignment during execution, and it may be different each time the function is called. The bind() method can...
Read more >
Properties without the default value do not accept undefined
This declaration makes it impossible to bind a variable that has an undefined type. The proper declaration is: TypeScript. @Input() get width(): ...
Read more >
Set Default If Null or Undefined Angular - Code Handbook
With Angular 12 version you can use Nullish coalescing operator ?? in templates to set default values if value is null or undefined....
Read more >

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