user1177440
user1177440

Reputation:

AngularJS - Actual values not being passed from drop down

In my html:

enter image description here

<li data-ng-repeat="module in sbVM.partialModules" data-ng-click="sbVM.selectModule('{{module.id}}', '{{module.name}}')">{{module.name}}</li>

Compiled HTML:

enter image description here

In my code behind:

    sbVM.selectModule = function (id, name) {
        sbVM.selectedModuleId = id;
        sbVM.selectedModule = name;
        activate(sbVM.selectedModuleId);
    };

In Chrome debugger:

enter image description here

And I get this error:

enter image description here

When the values are hard coded in the html, everything is fine:

<li class="selectModule" data-ng-click="sbVM.selectModule('1', 'Personal Module')"></li>
<li class="selectModule" data-ng-click="sbVM.selectModule('2', 'Website Module')"></li>
<li class="selectModule" data-ng-click="sbVM.selectModule('3', 'Commerce Module')"></li>
<li class="selectModule" data-ng-click="sbVM.selectModule('4', 'Super Admin Module')"></li>

But that obviously is not what I want. As you can see from the debugger, the actual values are not being passed, only the controller's property names. Can anyone explain the problem?

Upvotes: 0

Views: 41

Answers (1)

mpm
mpm

Reputation: 20155

    <li data-ng-repeat="module in sbVM.partialModules" 
     data-ng-click="sbVM.selectModule(module.id, module.name)">
   {{module.name}}
   </li>

ng-click expect an expression.

Upvotes: 1

Related Questions