Skip to main content

NDC London–Day 2

Yes, we survived day 2 of NDC London. With our heads filled with AngularJs, SignalR and Web API knowledge we spent the evening shopping in the Westfield mall after enjoying a delicious meal at one of Jamie Oliver’s Italian restaurant.  I’m still digesting the great food and all the new things we learned. 

You can find my sample code here: https://github.com/wullemsb/NDC-London---Angular-Day-2

And here are my notes of day 2 of the workshop.

Overriding Services

  • You can overwrite any service bij creating a new factory registration
  • Last registration wins…

Decorating Services

  • Add pre- and post processing logic
  • Use $provide.decorator()

Service Providers

  • Different way to create services(there are multiple, remember)
  • Use $provide
  • Configure the service during the configuration phase(2 phases as you should know; configuration and run phase)

Service Constants

  • Inject primitives as a service

Service Values

  • Similar to Constants, can also inject a value
  • The only difference is that constants are available in the config phase, values are only available during the run phase

Service factories

  • Another way to create a service and service provider

Service operator

  • Another(yes indeed) way to create a service and provider
  • Difference is that with a service you need to attach the service to the this object
  • Scott says "don't use it"

HTTP Interceptors

  • Request and response interceptors

HTTP Transforms

  • Transform the request and response itself

Resources

  • Gives you a very simple GET,PUT, POST, DELETE interface to your Web API

Extending HTML

  • Give you custom HTML elements through the use of directives
  • Most directives work in multiple ways
    • As an element <accordion>
    • As an attribute <div accordion>
    • As a class <div class=accordion> --> Avoid this one, it's confusing to find out if its a CSS class or directive

Event Directives

  • Multiple events are available out-of-the-box

Custom Directives

  • Build your own directives through a Directive Definition Object
  • Can become quit complex
  • With the restrict option you can specify how the directive can be used(as an element,…)

clip_image001

  • Note that you should call it as otc-greeting

clip_image002

  • Transclude option
    • Take the content from your custom directive and merge it with the template
  • Scope option
    • Allows you to create an isolated scope(by default the scope of the parent controller is used)
      • Useful for re-usable widgets
    • You can also create a new inherited scope
  • Compile function
    • Is called once for every directive
    • Can be used to manipulate the template
    • Most of the time you don't need this
  • Link function
    • Is called

Angular.element

  • Uses jQuery Lite; "the 20% jQuery you used all the time"

Testing

  • One of the core concepts of Angular is that it should be testable
  • Helps avoid global state and singletons through dependency injection
  • Helps separation of concerns by splitting out responsabilities over controllers, templates, services, etc…
  • Framework options
    • Qunit
    • Jasmine
    • Mocha
  • Test runner options
    • Karma
    • Grunt
    • Chutzpah

Mocking

  • Through angular-mock.js(part of the NuGet package)
  • Use $httpBackend to test HTTP interaction

Routing

  • Very important part of Angular
  • Use ngView
  • RouteProvider used during configuration phase
  • Is available as a separate NuGet package
  • Include the module

clip_image003

  • Multiple Routing Events are available
  • You can also use HTML 5 routing if you don't like the # sign in your URL's

ngAnimate

  • Separate module(angular-animate.js)
  • Supports CSS transitions and animations
  • Contains a list of built in animations

UI Bootstrap

clip_image004

Annoyances(again) :-(

  • Kind of confusing combination of service constants and service values
  • Custom directives can be quit complex
    • Especially if you start to play with the scope

Popular posts from this blog

DevToys–A swiss army knife for developers

As a developer there are a lot of small tasks you need to do as part of your coding, debugging and testing activities.  DevToys is an offline windows app that tries to help you with these tasks. Instead of using different websites you get a fully offline experience offering help for a large list of tasks. Many tools are available. Here is the current list: Converters JSON <> YAML Timestamp Number Base Cron Parser Encoders / Decoders HTML URL Base64 Text & Image GZip JWT Decoder Formatters JSON SQL XML Generators Hash (MD5, SHA1, SHA256, SHA512) UUID 1 and 4 Lorem Ipsum Checksum Text Escape / Unescape Inspector & Case Converter Regex Tester Text Comparer XML Validator Markdown Preview Graphic Color B

Help! I accidently enabled HSTS–on localhost

I ran into an issue after accidently enabling HSTS for a website on localhost. This was not an issue for the original website that was running in IIS and had a certificate configured. But when I tried to run an Angular app a little bit later on http://localhost:4200 the browser redirected me immediately to https://localhost . Whoops! That was not what I wanted in this case. To fix it, you need to go the network settings of your browser, there are available at: chrome://net-internals/#hsts edge://net-internals/#hsts brave://net-internals/#hsts Enter ‘localhost’ in the domain textbox under the Delete domain security policies section and hit Delete . That should do the trick…

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.