javascript - Call a function in ng-repeat -


i have array names of buttons , names of function called when button clicked.

if ng-repeat through buttons works fine, except function not being executed. i'm not sure else can try, or if it's possible.

here data

$scope.something = [{     name: 'cool button',     func: 'test' }, {     name: 'another button',     func: 'something' }] 

and i'm using ng-repeat so.

<button ng-click="some.func" ng-repeat="some in something">{{some.name}}</button> 

here things have tried function working.

some.func // nothing happens some.func() // throws error {{ some.func }}() // nothing happens 

here 1 of functions that's called

$scope.test = function() {     alert('clicked'); }; 

is possible?

a quick fiddle made.

ng-click="this[some.func]()" 

or reference function directly:

$scope.something = [{     name: 'cool button',     func: $scope.test }, {     name: 'another button',     func: $scope.anotherfunc }]  ng-click="some.func()" 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -