使用$ ionic Popup

时间:2016-09-29 10:08:10

标签: angularjs ionic-framework

你好我用离子来创建一个简单的弹出窗口。这里我点击按钮后无法显示弹出信息。我不知道哪里出错了,请帮我显示弹出窗口。我得到错误

ionic.bundle.js:26794 TypeError: Cannot read property 'show' of undefined
    at Scope.$scope.showPopup 

link

angular.module('CarWash',[$ionic]).controller('popSelect',['$scope',function($scope,$ionicPopup){
$scope.data={};
$scope.showPopup = function() {
       $ionicPopup.show({
            title:'select car wash',
            template: "Hello customer !!!",

        });
        alertpop.then(function(res){
          console.log('Inside pop-up');

1 个答案:

答案 0 :(得分:0)

你在依赖注入中搞砸了,你必须注入$ionicPopup才能在控制器工厂函数中使用它。

angular.module('CarWash',[$ionic])
.controller('popSelect',['$scope', '$ionicPopup', //<-- injected $ionicPopup here
   function($scope, $ionicPopup){ //<-- now you can access $ionicPopup instance here.