Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Working

SquadWuschel squadwuschel

💭
Working
View GitHub Profile
@squadwuschel
squadwuschel / customHttp.core.module.ts
Created Jan 21, 2017
Registrieren unserer CustomHttp Erweiterung und überschreiben der Standard Http Implementierung
View customHttp.core.module.ts
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 Jan 21, 2017
Implementieren unseres httpSubjectServices und die Subjects Subscriben
View app.component.ts
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 Jan 21, 2017
Service der mehrere jxjs Subjects bereitstellt
View httSubjectService.ts
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 Jan 21, 2017
CustomHttp für Angular 2 als Interception Ersatz.
View customHttp.ts
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 Dec 8, 2016
Angular 2 mit Webpack 2 beta 27
View package.json
{
"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 Dec 7, 2016
HomeController zum Laden einer Index.html
View HomeController.cs
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 Dec 7, 2016
RouteConfig für Angular 2 mit webpack 2
View RouteConfig.cs
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 Dec 7, 2016
Compillierte index.html im wwwroot für Angular 2 mit webpack 2
View index.html
<!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 Dec 7, 2016
Angular 2 mit webpack 2 dev Einstellungen
View webpack.dev.js
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 Dec 14, 2016
Angular 2 und webpack 2 - webpack.common.js mit LESS und SASS Loader
View webpack.common.js
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');
You can’t perform that action at this time.