When setting up unit tests for a module you need to make sure that your test harness is aware of any dependancies that module has. It doesn't stop there though; you also need to make sure that you include the dependancies of your dependancies. And so it goes on. Thankfully all dependancies are injected in the same way.
A blog about coding in AngularJs, how different functionality works, and how to set up supporting technologies.
Showing posts with label Dependancy injection. Show all posts
Showing posts with label Dependancy injection. Show all posts
Sunday, 7 June 2015
Sunday, 22 February 2015
Use ng-annotate with Grunt in WebStorm
After my last post on using $inject for protecting your dependancy injection against minification I did some further reading on ng-annotate. In his style guide, John Papa says that he uses
$inject
because it mirrors the technique used by ng-annotate, which he uses to automatically create minification safe dependancies and here is how you can too.
Labels:
$inject,
AngularJs,
Dependancy injection,
Grunt,
WebStorm
Location:
United Kingdom
Wednesday, 18 February 2015
Use $inject for Better Dependency Injection
By now we should all be aware that if you minify your AngularJs code without building in some protection against it, then we can easily lose the references we've entered into the factory / controller / etc. without realising until we fill the console up with errors. Since the beginning I've been using the traditional inline array style protection. This is fine if you have only a couple of dependancies, but soon becomes a readability nightmare when you have any more. Whilst reading through the AngularJs Style Guide by John Papa I came to his recommendation of using $inject. I'm now a convert.
Labels:
$inject,
AngularJs,
Dependancy injection
Location:
United Kingdom
Subscribe to:
Posts (Atom)