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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -