【问题标题】:Angular alert input returns 'undefined'角度警报输入返回“未定义”
【发布时间】:2016-01-12 20:32:20
【问题描述】:

我正在尝试在 ionic 弹出窗口中打印输入值。但它在控制台中返回“未定义”,而不是在输入字段中输入的文本。我也尝试不使用$scope,但没有成功。它可能有什么问题?下面你可以看到我使用的代码。

function funcNew() {
        var myPopup = $ionicPopup.show({
            template: '<input type="text" ng-model="description">',
            title: 'Enter Description',
            subTitle: '',
            scope: $scope,
            buttons: [
                {
                    text: 'Cancel'
                },
                {
                    text: '<b>Yes</b>',
                    type: 'button-positive',
                    onTap: function (e) {
                        console.log($scope.description);

                    }
            }]
        });
    }

【问题讨论】:

  • 它是否说明了控制台中未定义的内容?
  • 不,它只是打印 'undefined' 而不是 'description' 的实际值。
  • 解决此问题的方法是发送console.log($scope),让您更深入地了解正在发生的事情

标签: angularjs ionic-framework ionic


【解决方案1】:

ng-modelconsole.log($scope.data.description) 中使用data.description 而不是description

【讨论】:

  • 很高兴知道这一点。谢谢!
猜你喜欢
  • 2019-10-09
  • 1970-01-01
  • 2016-03-20
  • 2021-10-01
  • 1970-01-01
  • 2018-04-12
  • 2019-04-14
  • 2020-10-22
  • 2020-12-03
相关资源
最近更新 更多