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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -