Skip to content

Instantly share code, notes, and snippets.

View squadwuschel's full-sized avatar
💭
Working

SquadWuschel squadwuschel

💭
Working
  • Relaxdays
  • Germany
View GitHub Profile
@squadwuschel
squadwuschel / customHttp.core.module.ts
Created January 21, 2017 20:32
Registrieren unserer CustomHttp Erweiterung und überschreiben der Standard Http Implementierung
import { NgModule, ValueProvider } from '@angular/core';
import { HttpModule, Http, XHRBackend, RequestOptions } from '@angular/http';
//Custom Http
import { HttpSubjectService } from './httpSubject.service';
import { CustomHttp as SxpCustomHttp } from './customHttp';
/**
* Das HTTP Module was alle Providers enthält. KEINE Components oder Pipes!
* Dieses Modul darf NUR ins CoreModules einbegunden werden.
@squadwuschel
squadwuschel / app.component.ts
Created January 21, 2017 20:25
Implementieren unseres httpSubjectServices und die Subjects Subscriben
import { Component } from '@angular/core';
import { HttpSubjectService } from "../HttpInterception/httpSubject.service";
import { Homeservice } from "../HttpServices/home.service";
@Component({
selector: 'app',
templateUrl: './app.component.html',
})
export class AppComponent {
private locals: AppLocalsModel = new AppLocalsModel();
@squadwuschel
squadwuschel / httSubjectService.ts
Created January 21, 2017 20:22
Service der mehrere jxjs Subjects bereitstellt
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
@Injectable()
export class HttpSubjectService {
//Wir registrieren ein Subject welches wir an anderer Stelle per Subscribe abfragen können
//Subscribe wird aufgerufen, wenn die Next Funktion ausgelöst wurde. Die Next Funktion wird im
//CustomHttp an der passenden Stelle aufgerufen für das jeweilige Subject.
//https://github.com/ReactiveX/rxjs/blob/master/doc/subject.md
public notificationSubject = new Subject();
@squadwuschel
squadwuschel / customHttp.ts
Created January 21, 2017 20:08
CustomHttp für Angular 2 als Interception Ersatz.
import { Injectable } from '@angular/core';
import { Http, ConnectionBackend, Request, RequestOptions, RequestOptionsArgs, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { HttpSubjectService as SxpHttpSubjectService } from './httpSubject.service';
//http://restlet.com/blog/2016/04/18/interacting-efficiently-with-a-restful-service-with-angular2-and-rxjs-part-3/
@Injectable()
@squadwuschel
squadwuschel / package.json
Last active December 8, 2016 06:52
Angular 2 mit Webpack 2 beta 27
{
"scripts": {
"start": "webpack-dev-server --inline --progress --port 8080",
"typings": "typings",
"postinstall": "typings install"
},
"dependencies": {
"@angular/common": "~2.2.0",
"@angular/compiler": "~2.2.0",
"@angular/core": "~2.2.0",
@squadwuschel
squadwuschel / HomeController.cs
Created December 7, 2016 10:53
HomeController zum Laden einer Index.html
namespace Angular2MitWebpack2.Controllers
{
public class HomeController : Controller
{
[AllowAnonymous]
public ActionResult Index()
{
//die Index.html wird von WebPack in das Verzeichnis kopiert und die Standardroute
//lädt dann automatisch die index.html
return new FilePathResult("~/wwwroot/index.html", "text/html");
@squadwuschel
squadwuschel / RouteConfig.cs
Created December 7, 2016 10:51
RouteConfig für Angular 2 mit webpack 2
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
@squadwuschel
squadwuschel / index.html
Created December 7, 2016 10:42
Compillierte index.html im wwwroot für Angular 2 mit webpack 2
<!DOCTYPE html>
<html lang="de">
<head>
<title>Angular2 Mit WebPack 2</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<!-- base url -->
@squadwuschel
squadwuschel / webpack.dev.js
Created December 7, 2016 10:34
Angular 2 mit webpack 2 dev Einstellungen
var helpers = require('./helpers');
var webpackMerge = require('webpack-merge'); // used to merge webpack configs
var commonConfig = require('./webpack.common.js'); // the settings that are common to prod and dev
/**
* Webpack Plugins
*/
var DefinePlugin = require('webpack/lib/DefinePlugin');
var LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
var WebpackNotifierPlugin = require('webpack-notifier');
@squadwuschel
squadwuschel / webpack.common.js
Last active December 14, 2016 07:33
Angular 2 und webpack 2 - webpack.common.js mit LESS und SASS Loader
var webpack = require('webpack');
var helpers = require('./helpers');
var path = require('path');
var ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
var ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');