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 "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); |
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, 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 | |
}) |
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
using Microsoft.AspNet.Mvc; | |
namespace WebApplication1.Controllers | |
{ | |
public class PartialController : Controller | |
{ | |
public IActionResult Message() => PartialView(); | |
public IActionResult Numbers() => PartialView(); | |
} |
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
@{ | |
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; |
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
@{ | |
ViewBag.Title = "MVC"; | |
} | |
<mvc> | |
<blockquote *ngIf="message">{{message}}</blockquote> | |
</mvc> |
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, OnInit} from "angular2/core"; | |
@Component({ | |
selector: "mvc", | |
templateUrl: "/partial/message" | |
}) | |
export class MvcComponent implements OnInit { | |
message: string; | |
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
<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"> |
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
<static> | |
<blockquote>{{message}}</blockquote> | |
</static> |
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, OnInit} from "angular2/core"; | |
@Component({ | |
selector: "static", | |
templateUrl: "app/components/static.html" | |
}) | |
export class StaticComponent implements OnInit { | |
message: string; | |
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
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] |