angularjs - javascript how to create function service (constructor) -
in angularjs if invoke service method:
app.service('nameservice', function(){ this.service = function (){console.log('hello')} }
then can use service (object) : nameservice.service() question how can write function have 2 arguments(name, function)
function service ( name, function ){ // how angular declare object value of first argument ? }
i'm ask how write function service(name,fn){} ?
angularjs use dependency injection inject service.
"service" method available on angular object because on prototype.
angular.prototype.service = ...
you can read more prototype inheritance, mdn - inheritance , prototype chain
Comments
Post a Comment