Skip to content

Instantly share code, notes, and snippets.

View chgc's full-sized avatar
🎯
Focusing

Kevin Yang chgc

🎯
Focusing
View GitHub Profile
@chgc
chgc / demo.component.spec.ts
Last active May 3, 2018 06:19
如何使用 overrideModule / overrideProvider 等方法
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { ActivatedRoute } from '@angular/router';
import { DemoComponent } from './demo.component';
import { of } from 'rxjs/observable/of';
import { NgModule } from '@angular/core';
@NgModule({
declarations: [DemoComponent],
providers: [
import { Subject } from 'rxjs/Subject';
import { TokenInfo } from './tokeninfo';
//import { Token } from './checktoken';
//import { Applist } from './applist';
//import { ApplistWithVersion } from './applistwithversion';
import { Injectable, Input } from '@angular/core';
import { Http } from '@angular/http';
import { ActivatedRoute } from '@angular/router';
import {Observable} from 'rxjs/Observable';
@chgc
chgc / app.component.ts
Created June 8, 2017 13:20
use Map 來儲存 service
import {Component, Inject, Injector} from '@angular/core';
import {serviceToken} from './app.module';
import {IService} from './iservice';
import {Service1Service} from './service1.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
@chgc
chgc / app.component.ts
Created June 7, 2017 07:53
providers: 使用 multi 的情境
import {Component, Injector} from '@angular/core';
import {serviceToken} from './app.module';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
@chgc
chgc / app.component.ts
Last active May 27, 2017 15:36
用 Angular 來開發 Excel 增益集 (addin),使用官網範例改寫
import 'rxjs/add/observable/from';
import {ApplicationRef, Component} from '@angular/core';
import {Observable} from 'rxjs/Observable';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
@chgc
chgc / app.module.ts
Created April 1, 2017 01:42
MaterialModule in Angular Universal (Angular 2.x)
import { NgModule, CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
import { RouterModule } from '@angular/router';
import { UniversalModule, isBrowser } from 'angular2-universal';
import { MaterialModule } from '@angular/material';
import { AppComponent } from './components/app/app.component'
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { HomeComponent } from './components/home/home.component';
import { FetchDataComponent } from './components/fetchdata/fetchdata.component';
import { CounterComponent } from './components/counter/counter.component';
@chgc
chgc / web.config
Created March 14, 2017 02:28
SPA rewrite rule - web.config version
...
<rewrite>
<rules>
<rule name="SPA" stopProcessing="true">
<match url=".*" />
<action type="Rewrite" url="/" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
</rule>
@chgc
chgc / app.request.ts
Last active August 9, 2017 22:44
Play with BaseRequestOptions in Angular2
import { Injectable, Inject } from '@angular/core';
import { BaseRequestOptions, RequestOptions, Headers, RequestOptionsArgs } from '@angular/http';
@Injectable()
export class AppRequestOptions extends BaseRequestOptions {
constructor() {
super();
}
merge(options?:RequestOptionsArgs):RequestOptions {
@chgc
chgc / MessagesController.cs
Last active April 6, 2016 07:09
BotBuilder -Custom Dialog
internal static IDialog MakeRootDialog()
{
return new SandwichDialog(SandwichOrder.BuildForm);
}
public async Task<Message> Post([FromBody]Message message)
{
if (message.Type == "Message")
{
return await Conversation.SendAsync(message, MakeRootDialog);