angularjs - Make a dynamic function on ng-click -


i have button this

<button ng-click="method = 'create'; title = 'create'>create</button> <button ng-click="method = 'update'; title = 'update'>update</button> 

and this

<button ng-click="create(param)">{{ title }}</button> <button ng-click="update(param)">{{ title }}</button> 

code above works fine, want make dynamic.

so change following.

<button ng-click="{{ method }}(param)">{{ title }}</button> 

this not work, dont know why, although if inspect element, code above generates corrects code mentioned before.

use of bracket notation:

<button ng-click="this[method](param)">{{ title }}</button> 

this points current scope object this[method] can access method via variable name.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -