I'm using the resolve functionality with a couple of controllers to fetch some data before the rendering of a new view kicks in like this:
HomeCtrl.resolve = { pictures: function(Picture) { return Picture.getall(); } };
How do I write this so the Picture-service, that is passed as an argument, doesn't get overwritten when minified?
Alternatively, you can use ng-annotate npm package in your build process to avoid this verbosity. Instead of using this more verbose syntax you can use ngmin and a build tool (like Grunt) before you run minification. That way you can minify properly but also use either dependency injection syntax.
Dependency Injection in AngularJS can be defines as the software design pattern which defines the way the software components are dependent on each other. AngularJS provides a set of components that can be injected in the form of dependencies such as factory, value, constant, service, and provider.
Injecting a value into an AngularJS controller function is done simply by adding a parameter with the same name as the value (the first parameter passed to the value() function when the value is defined). Here is an example: var myModule = angular. module("myModule", []); myModule.
26) Which of the following components can be injected as a dependency in AngularJS? Answer: D is the correct answer. The "Application Module" can be injected as a dependency in AngularJS.
You can inject the dependencies using the following pattern, it is minification proof
HomeCtrl.resolve = { pictures : ['Picture', function(Picture) { return Picture.getall(); }] };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With