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

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -