Preslav's Thoughts and Ramblings


  • 01 May 2016

    FIX: Angular2 - Missing Http Function

    The first Http example that most new Angular 2 users get to try their hands on, is this code snippet taken from the Angular 2 Http Docs: import {Http, HTTP_PROVIDERS} from 'angular2/http'; @Component({ selector: 'http-app', viewProviders: [HTTP_PROVIDERS], templateUrl: 'people.html' }) class PeopleComponent { constructor(http: Http) { http.get(...

  • 23 January 2016

    Injecting Services in Angular 2 and Ionic 2

    Create a service: import {Injectable} from 'angular2/core'; @Injectable() export class MyService { constructor(http: Http) { // initalize things } doSomething() { // do something } } Injecting the newly created service per component In vanilla Angular 2.0, as well as in Ionic 2 applications, you need to import the service class and add it to...

  • 22 August 2015

    ngMock Helpers

    Let’s take a controller test straight out of the Angular JS Docs: describe('PasswordController', function() { beforeEach(module('app')); var $controller; beforeEach(inject(function(_$controller_){ // The injector unwraps the underscores (_) from around the parameter names when matching $controller = _$controller_; })); describe('$scope.grade', function() { it('sets the strength to "strong"...