This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require("express") | |
var path = require("path") | |
var app = express() | |
app.use(express.static(path.join(__dirname, 'public'))) | |
app.get('/', (req, res, next) => { | |
res.sendFile('index.html') | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sess = require('express-session'); | |
let RedisStore = require('connect-redis')(sess); | |
let opts = { | |
host: 'redis-server-hostname', | |
port: 'redis-server-port', | |
url: 'redis-server-url' | |
client: 'add your existing redis client', | |
socket: 'redis-unix-socket' | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AppComponent { | |
constructor(public state = 'inactive') { } | |
toggleState() { | |
this.state = this.state === 'active' ? 'inactive' : 'active' | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core' | |
import { Http } from "@angular/http" | |
import 'rxjs/add/operator/map' | |
@Injectable() | |
export class ApisService { | |
host: String = 'https://websitename.com' | |
constructor(public http: Http) { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from "@angular/core"; | |
import { MyService } from "../services/my-service.service.ts" | |
@Component({ | |
selector: '.header', | |
providers: [ MyService ] | |
}) | |
export class Users { | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
viewProviders: [ HttpService ], | |
template: ` | |
<div class="user-profile"> | |
Username: {{username}} | |
Email: {{email}} | |
</div> | |
`, | |
styles: ['.user-profile: { background-color: #333, color: "white" }'] | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { BehaviorSubject } from 'rxjs/BehaviorSubject'; | |
@Injectable() | |
export class DataService { | |
navState = new BehaviorSubject<>(); | |
navState = this.dataSource.asObservable(); | |
constructor() { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myMap = () => { | |
let kisumu = new google.maps.LatLng(-0.0917,34.7680); | |
let msa = new google.maps.LatLng(-4.0435,39.6682); | |
let nairobi = new google.maps.LatLng(-1.2921,36.8219); | |
let mapCanvas = document.getElementById("map"); | |
let mapOptions = {center: nairobi, zoom: 6}; | |
let map = new google.maps.Map(mapCanvas,mapOptions); | |
let flightPath = new google.maps.Polyline({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myMap = () => { | |
let nyeri = new google.maps.LatLng(-0.4371,36.9580); | |
let nairobi = new google.maps.LatLng(-1.2921,36.8219); | |
let machakos = new google.maps.LatLng(-1.5177,37.2634); | |
let mapCanvas = document.getElementById("map"); | |
let mapOptions = {center: nairobi, zoom: 8}; | |
let map = new google.maps.Map(mapCanvas,mapOptions); | |
let flightPath = new google.maps.Polygon({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let express = require('express') | |
let bodyParser = require('body-parser') | |
let path = require('path') | |
let mongoose = require('mongoose') | |
//import Student Model from ./models | |
let Student = require('./models/student.js') | |
//initialize express app | |
let app = express() | |
//configure express app to parse json content and form data | |
app.use(bodyParser.urlencoded({ extended: false })) |
OlderNewer