javascript - How about assign function from service in controller -


how assign function instead of create new function in controller in angularjs? why do?, why don't?

to this:

//controller example function examplectrl(customservice) {     var example = this;     example.doany = customservice.doany; } 

instead of this:

//controller example function examplectrl(customservice) {     var example = this;     example.doany = doany;      function doany() {         customservice.doany();     } } 

i doubtful becouse of this: https://material.angularjs.org/latest/demo/dialog take of dialogcontroller in js tab.

many thanks.


Comments