Monday, April 2, 2018

Did you know that you can use the selector for an Angular 4 component not just as the definition for its own tag at the templates, but also...

...like so:

<tr my-selector-name></tr>

 
 

It may be nested inline in another tag!

 
 

Addendum 5/2/2018: At the component's metadata properties the string for selector should start and end with square brackets in order for this to work.

{{myArray.push(13)}}

At an Angular 4 template's markup this will return the most recent position for the array, basically a number one less than the count of the array given the zero-based numbering system. A coworker and I worked this out today as my coworker had a friend who got asked this question as a gotcha interview question.

Toogle device toolbar

At upper left corner of the Google Chrome Developer Tools, no matter what tab you are on, is an icon that looks like a Northwestwardly pointing arrow penetrating a square which has a tooltip reading "Select an element in the page to inspect it" when you mouse over it and which is of course used for inspecting page elements. To the immediate right of it there is now an icon that looks like a smartphone sitting by a sheet of paper which has "Toogle device toolbar" as a tooltip and when clicked that does some distressing things to the header and footer of the web site at hand. Just click it again to make the effect go away. I guess it is for emulating a smartphone experience. You will notice the page cut off with the cut off part represented by some sort of downward expandable pane otherwise. Yuck.

.replace in JavaScript only replaces the first match in a string and .replaceAll only exists in jQuery so how may I have a .replaceAll emulation in other JavaScript frameworks?

You use a hodgepodge of .split and .join like so to achieve the same effect.

var xml = "<foo><bar>Bar</bar><baz>Baz</baz><qux>Qux</qux></foo>";
var changeOne = xml.split("<").join("&lt;");
var changeTwo = changeOne.split(">").join("&gt;");
alert(changeTwo);

Sunday, April 1, 2018

Black Mirror

A coworker from my job before the move to St. Louis recommended the Netflix series "Black Mirror" and I have just today finished watching all of the shows. It is mostly good. It is kinda like "The Twilight Zone" in that every show is an independent story. Various actors and directors collaborate. There is an episode directed by Jodie Foster for example. It's got both British and American talent. The first two seasons are just British, having played on British television a little after I started this blog. December 4th of 2011 would have been the first airing of the first show. Anyhow, I guess it disappeared and then Netflix picked it up and now it's got a hodgepodge of British and American influences. We are on season four now and that has been around since the end of last year. While a Twilight Zone episode could be about anything, there are not any Black Mirror shows about say a magic necklace (or was that a stopwatch) that freezes time. Black Mirror is consistently about technology and often technology represented in sinister futuristic extrapolations. A lot of it might as well be about magic though as it just seems farfetched to me. The over-the-top nature does not ruin the show though. It is probably better that we get crazy than that we don't in terms of keeping the audience engaged. The fourth show of the fourth season, Hang the DJ, is the best show. It has a pretty enchanting star in a Ms. Georgina Campbell who I had not seen before and also has the most intriguing premise with regards to tech. Basically, in order for a dating service to match you, you have to go out of a few practice dates. Metrics and data are slurped off the experiences and that is used in an algorithm for better matching. This really had my attention because as far as I know match.com and the like do not refine their matching based on a user's history, narrowing in on a lower likelihood of a mispairing. It was rumored that match.com just doesn’t work if you're not Christian for example. But won't the dating game eventually go this direction? It seems like this episode is predicting the future. Good job guys! I recommend Black Mirror.

Addendum 4/2/2018: "Hang the DJ" is kinda like the film "The Lobster" only a little better. I wanted to mention that yesterday but forgot to do so. It was Easter, April Fools, and the Persian New Year so I was distracted I guess.

Press the power button on the top right of an iPhone X in tandem with the volume up button at the left top of the phone to take a screen grab.

I figured this out today in absence of the "big button" which is now gone from the modern design. I'm pretty proud of myself. If you hold these buttons too long it will power the phone off, but not before prompting you to use a slider to do so. The power button by itself turns the phone back on but it doesn't want to work until a few seconds pass after a power down.

Don't expect injecting table rows with ng-content to behave well in Google Chrome in an Angular 4 application.

Not if the table tag and the header are outside the ng-content. It works OK in IE, but in Google Chrome though something falls down and the width of a table cell will not be consistent in a row cell and header cell. The overall rules of the table with regards to what should be consistent widths are not enforced. I have noticed that Angular sprinkles its only HTML tags in the markup and then its JavaScript must somehow be explicitly ignoring these so that they do not behave like divs. Anyhow the stuff outside of the ng-content and the injected rows have some different inline settings in these funny tags I have noticed. I do not know if that is what is behind the Chrome gremlin.