Wonjun Hwang
Wonjun Hwang

Reputation: 51

In Ionic popover, pass parameter to scope by ng-click

I can't get parameter variable(range value) in ionicPopover's range input. Is there any problem in scope? or anything?

[in Controller.js]

.controller('AppCtrl', function(...) {

    $scope.selectValue = function(rangeVal) {
        console.log(rangeVal);         //print 'undefined'
        console.log($scope.rangeVal);  //print 'undefined'
        console.log("hello?");         //print 'hello?'
    };

    $ionicPopover.fromTemplateUrl('templates/popover.html', {
        scope: $scope
    }).then(function(popover) {
        popover.show(".popover");
    });

[in popover.html]

<ion-popover-view>
    <ion-content>
        <div class="item range">
            <input type="range" name="rangeVal" min="0" max="100" ng-model="rangeVal">
        </div>
        <button ng-click="selectValue({{rangeVal}})">OK</button>
    </ion-content>
</ion-popover-view>

in [ion-popover-view] I can watch variable changing

but after click, $scope.selectValue function can't get parameter....

Upvotes: 0

Views: 2916

Answers (1)

taxicala
taxicala

Reputation: 21789

you dont need the curly bracers to call a function in angular (neither to pass a parameter to that function):

<button ng-click="selectValue(rangeVal)">OK</button>

Upvotes: 2

Related Questions