JavaScript
YADNC3JSG–Yet Another .NET Core 3.0 JSON Serializer Gotcha
Previously I wrote about several “gotchas” in the new JSON serializer that is built in to .NET Core 3.0. Another one has cropped up, but it is different enough that I thought it warranted its own post. Type Promiscuity via GIPHY Back in 2010 or something like that, Ted Neward gave a talk about JavaScript … [Read more…]
TypeScript – Enumerating object properties with Object.keys
One of the benefits of JavaScript (and therefore TypeScript) is being able to do whatever you want with objects. This can be dangerous, of course, because of type promiscuity – which is one thing that TypeScript addresses. via GIPHY Object.keys Sometimes it is still useful to just loop through each property on an object in … [Read more…]
Angular date picker with NgbDatePicker
DatePickers are pretty much a dime a dozen these days, but if you are already using a framework that already has a DatePicker, it makes sense to use that. via GIPHY ng-bootstrap ng-bootstrap is a package of Angular components that are built using Bootstrap 4. So, if you’re already using Bootstrap and Angular, it could … [Read more…]
Uploading a file from a website
Uploading a file from a website is pretty simple, but I always have to look it up. There’s all sorts of different technologies and frameworks that work with the web, so I just thought I would write down how I got it to work so that next time I can just come back here and … [Read more…]
NaN !== NaN
So there I was, minding my own business, again writing JavaScript tests… when suddenly I wanted to write a test to see what happens if NaN was supplied as a parameter. via GIPHY NaN Stands for “Not A Number”. You can get a NaN in a few different ways: But when checking for NaN, there’s … [Read more…]
[object ErrorEvent] thrown … again
So there I am, happily writing unit tests, and suddenly this appears I keep seeing this error while trying to write Angular tests. I… *think* this happens when something goes wrong during the constructor of a component. I’ve written before about how it could be due to an @Input property not being initialized properly. But, … [Read more…]
Javascript–Caching a web request with Promises
Suppose you have some data that comes from a web server somewhere. But, it doesn’t change – so we really only need to fetch it once, and then store the result for easy access (maybe its an Enum that you map to a list of key/value pairs). We can do this easily enough in a … [Read more…]
Unit Testing NgbModal Modal Service
In the last blog post I showed how you could extend NgbModal to make a Modal Service, letting you re-use modal dialogs easily from within your Angular components. Even though its not always that much fun, I like to try and keep testability in mind when writing code… and, I’ll admit it, sometimes I gloss … [Read more…]
Angular–Displaying objects as JSON
Sometimes, especially when you’re debugging or planning out your component layouts, it can be useful to just write out the entire object as JSON so you can see just what you’re dealing with. You can do this in Chrome’s console usually with good results, but sometimes it would be easier to see it in the … [Read more…]