0

I'm tryng to get data from view that must be passed as parameter in a function to populate an array in the controller. But the objects return me nothing, here what i have done:

VIEW

        <div ng-repeat="cssframework in voce.framewrok">
        <input type="checkbox" ng-onchange="AggiornaTotale({{cssframework.costo}})"/>  
        <span>{{cssframework.name}}........<b>{{cssframework.costo | currency}}</b></span>
      </div>    
<div class="row">
    <h3>TOTALE: {{selectedVoices[0]}}</h3>
</div>

ng-onchange trigger the function "AggiornaTotale" and pass cssframework.costo as parameter, the goal in the controller, is to populate an array named "selectedVoices"

CONTROLLER

    $scope.AggiornaTotale = function(param) {
    $scope.selectedVoices = [];
    this.selectedVoices.push(param);
}   

Why i don't see {{selectedVoices[0]}} updated? Thank you for advice

2 Answers 2

2

replace ng-onchange with ng-change

Sign up to request clarification or add additional context in comments.

2 Comments

and ng-change works only if ng-model exists on same tag
yep i see, now if i check it change the model too
1

change

ng-onchange="AggiornaTotale({{cssframework.costo}})

to

ng-change="AggiornaTotale({{cssframework.costo}})

and controller to

 $scope.AggiornaTotale = function(param) {
    $scope.selectedVoices = [];
    $scope.selectedVoices.push(param);
 }   

1 Comment

cool, it works. but can you tell me why <b>{{cssframework.costo | currency}}</b disappear?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.