vrghost
vrghost

Reputation: 1224

generated ng-click does not send variables

Have a problem with a generated ng-click event.

Basically, I generate the following code:

<button class="padbtn" data-ng-click="playBeat({sndType: smpBeat, sndId:C0})">
    <img class="padImg" src="/api/getImg/554240a17b221e1a2ffda097" style="width:175px; height 175px;"/>
    <br/>
    Boat
</button>

This is then compiled and added to a div. There is (in the same controller) a function called playBeat:

$scope.playBeat = function (sndType, sndId){                
    console.log('Was asked to play '+ sndId);               
}   

It gets called, but for some reason it does not receive the sndType or sndId, and in both cases it comes back with

BabyDevel.js:134 Was asked to play undefined

Not really certain what to make of this issue, or even where I can debug it, quite certain it is sending the options though.

== UPDATE == I also tried

<button class="padbtn" data-ng-click="playBeat(smpBeat,C0)"><img class="padImg" src="/api/getImg/554240a17b221e1a2ffda097" style="width:175px; height 175px;"/><br/>Boat</button>

Without the JSON, but that had the same effect.

Upvotes: 0

Views: 52

Answers (1)

Varedis
Varedis

Reputation: 758

The correct use would be

data-ng-click="playBeat(smpBeat, C0)"

Upvotes: 1

Related Questions