【问题标题】:In Ionic popover, pass parameter to scope by ng-click在 Ionic popover 中,通过 ng-click 将参数传递给范围
【发布时间】:2015-10-08 15:09:47
【问题描述】:

我无法在 ionicPopover 的范围输入中获取参数变量(范围值)。 范围有问题吗?还是什么?

[在 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");
    });

[在 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>

在 [ion-popover-view] 我可以看到变量的变化

但是点击后,$scope.selectValue 函数无法获取参数......

【问题讨论】:

  • 谢谢,它有效!我为这个问题感到羞耻:(

标签: angularjs ionic popover


【解决方案1】:

您不需要花括号来以角度调用函数(也不需要将参数传递给该函数):

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-22
    • 2018-07-21
    • 1970-01-01
    • 2015-04-21
    相关资源
    最近更新 更多