I try to understand the examples on angularjs.org. For example the following code snippet. How does this .value
and .factory
and .config
work?
angular.module('project', ['ngRoute', 'firebase'])
.value('fbURL', 'https://angularjs-projects.firebaseio.com/')
.factory('Projects', function($firebase, fbURL) {
return $firebase(new Firebase(fbURL)).$asArray();
})
.config(function($routeProvider) {
...
EDIT:
My point of not understanding the code above is the blank line after the first line and the line starting with a dot.
As standard dictates, unless there's a reason for ASI (like using postfix op, return
, continue
, throw
or break
statements), line terminators that separate language tokens are treated by JS as any other whitespace - that is, ignored. So these lines...
angular.module(arg1, arg2)
.value(arg3)
.controller(arg4)
.filter(arg5)
... are treated essentially the same as ...
angular.module(arg1, arg2).value(arg3).controller(arg4).filter(arg5)
So it's all about readability.
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