Skip to content

Instantly share code, notes, and snippets.

View natmegs's full-sized avatar

Natalie Smith natmegs

View GitHub Profile
@natmegs
natmegs / htmlController.js
Last active August 26, 2017 21:52
htmlController for second express example
var bodyParser = require('body-parser');
var urlencodedParser = bodyParser.urlencoded({ extended: false });
var jsonParser = bodyParser.json();
module.exports = function(app) {
// This contains all of the endpoints that return views/html.
// The function takes an app object and adds the endpoints
// to the app.
@natmegs
natmegs / apiController.js
Created August 26, 2017 21:29
apiController for second express example
module.exports = function(app) {
// This contains all of the endpoints that return views/html.
// The function takes an app object and adds the endpoints
// to the app.
app.get('/', function(req, res) {
res.send('<html><head><link href=assets/style.css type=text/css rel=stylesheet /></head><body><h1>Donuts</h1></body></html>');
});
app.get('/form', function(req, res){
@natmegs
natmegs / app.js
Created August 26, 2017 21:35
Express example using Router
var express = require('express');
var routes = require('./routes/index');
var users = require('./routes/users');
var app = express();
var port = process.env.PORT || 3000;
// path matching / will be handled by routes/index.js.
@natmegs
natmegs / users.js
Created August 26, 2017 21:36
users routes in express router example
var express = require('express');
// Router middleware;
// put GETs/POSTs/etc on Router
var router = express.Router();
// GET /users/
router.get('/', function(req, res, next) {
res.send('respond with a resource');
});
@natmegs
natmegs / index.js
Created August 26, 2017 21:37
index routes for express router example
var express = require('express');
// Router middleware;
// put GETs/POSTs/etc on Router
var router = express.Router();
// GET /index/
router.get('/', function(req, res, next) {
res.send('Root');
});
<script src="https://unpkg.com/@reactivex/rxjs@5.0.3/dist/global/Rx.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@natmegs
natmegs / host.component.ts
Created December 20, 2017 22:35
Skeleton host component
import { Component } from '@angular/core';
@Component({
selector: 'host',
templateUrl: './host.component.html',
styleUrls: [ './host.component.css' ]
})
export class AppComponent {
}
@natmegs
natmegs / host.component.html
Created December 20, 2017 22:36
Skeleton host template
<h1>We'll change this soon</h1>
@natmegs
natmegs / dynamic.component.ts
Created December 20, 2017 22:37
Dynamic component
import { Component, Input } from '@angular/core';
@Component({
selector: 'hello',
template: `<h1>Hello {{name}}!</h1>`,
styles: [`h1 { font-family: Lato; }`]
})
export class DynamicComponent {
@Input() name: string;
}
@natmegs
natmegs / host.component.ts
Created December 20, 2017 22:38
Add imports to host component
import { DynamicComponent } from './dynamic.component';
@Component({
selector: 'host',
templateUrl: './host.component.html',
styleUrls: [ './host.component.css' ],
entryComponents: [DynamicComponent]
})