Javascript Job Interview Question and Answer: Create multiple buttons with Javascript

How to make 20 buttons appear in the DOM by using javascript. I applied for a web developer job opening recently and I was asked to create a group of buttons with the text “Button” and the index number of the button written inside the button without writing any html. I had to use javascript to render these buttons in …

Angular4 Angular-material2 Table and Dialog: MySportsFeeds API Part 6

Angular-material2 dataTable. This app uses angular material2 dataTable module to show baseball player data. Run npm install –save @angular/material @angular/cdk Import it to app.module import {MdTableModule} from ‘@angular/material; Set it up in app.component define the table columns and pass data to the table. Call the dataTable in the app.component.html //app.compoent.ts import { Component, ViewChild, Inject, OnInit } from ‘@angular/core'; import …

Angular4 Make custom data: MySportsFeeds API Part 5

Make custom data. In this app I use one array to show all data in the views. I use 5 different endpoints to get different information about each player. In order to sort the data and apply it to the correct player I use the responses returned by the endpoints, for each loop through the response and match data by …

Angular4 Make multiple api calls dynamically: MySportsFeeds API Part 4

Make multiple api calls dynamically. In this app I needed to get a week worth of game data. To do this I need to get the schedule for the week and strip all the game ID’s then dynamically assign the id to call for each game and get detailed stats from that game. In app.component.ts import ‘rxjs/add/observable/forkJoin';. Make an api …

Angular4 with Firebase: MySportsFeeds API Part 3

Setting up FireBase. Install these modules for firebase config. Run npm install angularfire2 firebase –save. Import Firebase settings to app.module.ts. Create a firebase db and config the db in app.module.ts. Initialize app in the imports array in ngModule. //app.module.ts import { FirebaseService } from ‘./firebase.service'; import { AngularFireModule } from ‘angularfire2′; import { AngularFireDatabaseModule } from ‘angularfire2/database'; import { AngularFireAuthModule …

Angular4 deploy to Heroku: MySportsFeeds API Part 2

Deploy an Angular4 app to Heroku. For Heroku this app uses a node.js server app.js with express. All routes will be going to dist/index.html. Run ng build to build the app in the dist directory. Run node app.js to serve the app at http://localhost:3001. The Procfile in this app’s root specifies the server for heroku to use. //Procfile web: node …

Angular4 HttpClient: MySportsFeeds API Part 1

Get data from api with HttpClient module The first thing I want to do in this app is get a list of all the pitchers in major league baseball. I used the MySportsFeeds API to find the correct endpoint to get all pitchers. I am able to use Angular’s http module to send a GET request for data using this …

Angular.js ng-init with ng-repeat Propublica Congress API part 2

Use ng-init with ng-repeat to run multiple functions In this app I need to get all the bills voted on and the voting results of each bill that each state senator has voted on since the start of 2017. With this api first I get a senator by id and pass that into the endpoint that will return all the …

Angular.js $http request data from Propublica Congress API Part 1

This is a short example of how to get data back from the ProPublica Congress API using Angular’s $http service on the front end of an app. Get data from api with $http The first thing I want to do in this app is get a list of all the state senators in congress. I used the ProPublica api docs …

Angular.js and Angular-material comment form sent to inbox with nodemailer

Connect comment form to personal email inbox using $mdPanel It is easy to set up email functionality from an app. By installing a couple of NPM modules such as nodemailer you can have comments sent to your inbox with a few lines of code. Nodemailer and sendgrid do all the heavy lifting here making setting up complicated server calls to …