Call a function in ng-repeat
I have a array with some names of buttons and names of a function that is
to be called when the button is clicked.
If I ng-repeat through the buttons everything works fine, except the
function is not being executed. I'm not sure what else i can try, or even
if it's possible.
Here is some data
$scope.something = [{
name: 'Cool Button',
func: 'test'
}, {
name: 'Another button',
func: 'something'
}]
and I'm using ng-repeat like so.
<button ng-click="some.func" ng-repeat="some in
something">{{some.name}}</button>
Here are the things I have tried to get the function working.
some.func // Nothing happens
some.func() // Throws a error
{{ some.func }}() // Nothing Happens
here is one of the functions that's to be called
$scope.test = function() {
alert('clicked');
};
Is this possible?
A Quick Fiddle I made.
No comments:
Post a Comment