javascript - What do factory, service and dependency injection exactly mean in angular.js -
i little confused following angular.js concepts:
- factory
- service
- dependency injection
can brief me on each 1 simple example or explanation? appreciated.
these concepts part of javascript core.
regexp
factory:
console.log(regexp("[0-9]") ); console.log(regexp("[a-z]") ); console.log(regexp("[a-z]") ); console.log(regexp("[0-9a-za-z]") );
math
service:
console.log(math.pi); console.log(math.round(math.pi)); console.log(number(math.random() * 1000).tofixed()); console.log(number(math.random() * 10).toprecision(2)); console.log(math.floor(math.random() * 20) + 1);
call
, apply
dependency injection:
"use strict"; var foo = { min: function min(array) { return math.min.apply(math, array); }, max: function max(array) { return math.max.apply(math, array); } }; var bar = foo.min([1,2,3]); var baz = foo.max([1,2,3]); console.log("bar: " + bar); console.log("baz: " + baz);
references
Comments
Post a Comment