1/22/2019

New

  • Filtering & Sorting
  • Hosting Options
  • Cacher
  • Paging Content

Final Topics

  • Rotators
  • Responsive
  • jQuery
  • string contains
  • Adding events
  • Show/Hide
  • Ajax Get Request


Add the Angular Form Module

We need to inject the Angular form module into the application.

Set the stage


		menuItems: Array = [];
		allMenuItems: Array = [];

		filterProperty: String = 'name';
		filterDirection: String = 'asc';
	
		ngOnInit() {
			this.allMenuItems = this.menuService.getMenuItems();
			this.sort();
		}
	

Sort By Inputs

We are going to add a list of radio buttons to select what property we are going to sort by.




Update the ngModel and value attributes.

Items to note

  • [(ngModel)] - Represents the component variable associated with the control.
  • The input updates, the variable in code updates and vice versa.
  • [value] - the input value for the ngModel variable
  • "'price'" - The item inside quotes is treated like a JS object. We use the extra ' to convert the value to string.
  • (change) - binds an output event.
  • When this model is 'changed' sort the items

Add select element


 

Sort Code


const direction = (this.sortDirection === 'asc') ? 1 : -1;
this.menuItems.sort((a, b) => {
    if (a[this.term] < b[this.term]) {
    return -1 * direction;
    } else if (a[this.term] > b[this.term]) {
    return 1 * direction;
    } else {
    return 0;
    }
})

Hosting DNS and all that fun stuff

DNS

Domain Name System

This is where your website address gets stored. You have to have your URL registered before you can have a public site.

Read more here.

DNS Suggestions

  • Never buy for client
  • Buy Privacy
  • Auto Renew - maybe?

Traditional Hosting

Advantages

  • Fixed Cost
  • Support
  • Control Panels
  • Turn Key Installs

Disadvantages

  • Not Flexible Performance
  • "Shared" environments

Cloud Options

Advantages

  • Flexible Cost
  • Flexible Performance
  • Highly customizable

Disadvantages

  • Steep Learning Curve

General Suggestion

  • Don't host for people
  • Regularly check in
  • Keep it secure

GitHub Gists

Gists are small shared code snippets or individual files that don't need a full blown repository.

Docs

Gists are treated just like a repository.

You can update and modify existing ones.

Cacher

https://www.cacher.io/

Managing code snippets can be hard through the Github website. Cacher provides a clean and easy way to manage and share code snippets.

Pagination

Why Page?

  • Break apart large blocks of content.
  • Save load times.

We're going to look at code for this.

angular example
>