Skip to content

Instantly share code, notes, and snippets.

View IEvangelist's full-sized avatar
:octocat:
Coding for a better world 🤓

David Pine IEvangelist

:octocat:
Coding for a better world 🤓
View GitHub Profile
import "rxjs/Rx"
import {Http} from "angular2/http";
import {Injectable} from "angular2/core";
@Injectable()
export class ApiService {
constructor(private http: Http) { }
get(onNext: (json: any) => void) {
this.http.get("api/random").map(response => response.json()).subscribe(onNext);
import {Component, OnInit} from "angular2/core";
import {CORE_DIRECTIVES} from "angular2/src/common/directives/core_directives";
import {ApiService} from "./api.service";
@Component({
selector: "numbers",
templateUrl: "/partial/numbers",
providers: [ApiService],
directives: CORE_DIRECTIVES
})
using Microsoft.AspNet.Mvc;
namespace WebApplication1.Controllers
{
public class PartialController : Controller
{
public IActionResult Message() => PartialView();
public IActionResult Numbers() => PartialView();
}
@{
ViewBag.Title = "API";
}
<numbers>
<style>
.grey-border {
margin-top: 20px;
padding: 10px;
-webkit-box-shadow: 0 0 15px #999;
box-shadow: 0 0 15px #999;
@{
ViewBag.Title = "MVC";
}
<mvc>
<blockquote *ngIf="message">{{message}}</blockquote>
</mvc>
import {Component, OnInit} from "angular2/core";
@Component({
selector: "mvc",
templateUrl: "/partial/message"
})
export class MvcComponent implements OnInit {
message: string;
constructor() { }
<div class="page-header">
<h1>
MVC, Angular2
<br>
<small>Sample</small>
</h1>
</div>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<static>
<blockquote>{{message}}</blockquote>
</static>
import {Component, OnInit} from "angular2/core";
@Component({
selector: "static",
templateUrl: "app/components/static.html"
})
export class StaticComponent implements OnInit {
message: string;
constructor() { }
import {Component, OnInit} from "angular2/core";
import {AsyncRoute, Router, RouteDefinition, RouteConfig, Location, ROUTER_DIRECTIVES} from "angular2/router";
import {StaticComponent} from "./components/static.component";
declare var System: any;
@Component({
selector: "app",
templateUrl: "/app/app.html",
directives: [ROUTER_DIRECTIVES]