Sunday, December 30, 2018

I have finished chapter 5 of "ASP.NET Core 2 and Angular 5" by Valerio De Sanctis.

It is going to be my New Year's resolution to finish this book by the end of 2019. I am now halfway done. I bought the book in hopes of learning more about Entity Framework and Angularland authentication and there really hasn't been too much of that yet. I have flipped ahead and it is coming. I have become burned out on this book and I while I had been reading a page a day and typing some code in some of the exercises involved, I have fallen out of that habit and have instead read the most recent twenty-eight pages quickly to get to the halfway point before year's end. I am through two hundred sixty-three of five hundred seventeen pages and five of ten chapters. What was "new" in the most recent twenty-eight pages? Nothing. The content was mostly on making boilerplate Angular code with a hint of the introduce middleman base controller stuff on the C# side. What was a little different? Five things:

  1. Methods that a component template reaches out to inside of a component, perhaps when a user clicks a button or so, are referred to as delegate methods.
  2. Did you know that you may treat the snapshot URL off of an ActivatedRoute instance as an array like so?
    if (this.activatedRoute.snapshot.url[0]) {
       console.log("zero");
       console.log(this.activatedRoute.snapshot.url[0]);
       console.log(this.activatedRoute.snapshot.url[0].path);
    }
    if (this.activatedRoute.snapshot.url[1]) {
       console.log("one");
       console.log(this.activatedRoute.snapshot.url[1]);
       console.log(this.activatedRoute.snapshot.url[1].path);
    }

    I looked at my own blog and it looks like I touch on this trick here, in my this.whereAreWeReally example that I do not do anything with, but that doesn't really explain the trick and I did not even remember writing about it. The trick is that we will fish out the slash divided chunks of the URL so if http://www.example.com/yin/yang/ were our URL this.activatedRoute.snapshot.url[0].path gets us "yin" and this.activatedRoute.snapshot.url[1].path gives us "yang" in contrast.
  3. I know I have other SimpleChanges examples on this blog, but here is yet another in which we go-a-fishing for something in particular with the bracket notation instead of the dot notation or looping through all of the properties.
    ngOnChanges(changes: SimpleChanges) {
       if (changes['somethingToFishFor']) {
          console.log(changes['somethingToFishFor']);
       }
    }


    This should again allow you to taste what has changed (at a variable for an Input coming into the component from a wrapping component) and assess the situation.
  4. An example of two-way databinding to a select list that kinda looks like so is given.
    <select id="lives" name="lives" [(ngModel)]="cat.NumberOfLives">
       <option *ngFor="let num of [0,1,2,3,4,5,6,7,8,9]" [value]="numby">
          {{numby}}
       </option>
    </select>
  5. A number input type field in HTML might be a good forum for a nullable number type in TypeScript to match up to as a user may either give a number or leave it blank.

No comments:

Post a Comment