{"id":749,"date":"2018-02-25T20:33:24","date_gmt":"2018-02-25T12:33:24","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/25\/ionic-%e5%af%b9%e8%af%9d%e6%a1%86\/"},"modified":"2018-02-25T20:33:24","modified_gmt":"2018-02-25T12:33:24","slug":"ionic-%e5%af%b9%e8%af%9d%e6%a1%86","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=749","title":{"rendered":"ionic \u5bf9\u8bdd\u6846"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h1>ionic \u5bf9\u8bdd\u6846<\/h1>\n<hr>\n<h2>$ionicPopup<\/h2>\n<p>ionic \u5bf9\u8bdd\u6846\u670d\u52a1\u5141\u8bb8\u7a0b\u5e8f\u521b\u5efa\u3001\u663e\u793a\u5f39\u51fa\u7a97\u53e3\u3002<\/p>\n<p>$ionicPopup \u63d0\u4f9b\u4e863\u4e2a\u65b9\u6cd5\uff1aalert(), prompt(),\u4ee5\u53ca confirm() \u3002<\/p>\n<h2>\u5b9e\u4f8b<\/h2>\n<h3>HTML \u4ee3\u7801<\/h3>\n<pre>\n&lt;body class=\"padding\" ng-controller=\"PopupCtrl\"&gt;\n\u00a0\u00a0\u00a0\u00a0&lt;button class=\"button button-dark\" ng-click=\"showPopup()\"&gt;\n\u00a0\u00a0\u00a0\u00a0  \u5f39\u7a97\u663e\u793a\n\u00a0\u00a0\u00a0\u00a0&lt;\/button&gt;\n\u00a0\u00a0\u00a0\u00a0&lt;button class=\"button button-primary\" ng-click=\"showConfirm()\"&gt;\n\u00a0\u00a0\u00a0\u00a0  \u786e\u8ba4\u5bf9\u8bdd\u6846\n\u00a0\u00a0\u00a0\u00a0&lt;\/button&gt;\n\u00a0\u00a0\u00a0\u00a0&lt;button class=\"button button-positive\" ng-click=\"showAlert()\"&gt;\n\u00a0\u00a0\u00a0\u00a0  \u8b66\u544a\u6846\n\u00a0\u00a0\u00a0\u00a0&lt;\/button&gt;\n\n\u00a0\u00a0\u00a0\u00a0&lt;script id=\"popup-template.html\" type=\"text\/ng-template\"&gt;\n\u00a0\u00a0\u00a0\u00a0  &lt;input ng-model=\"data.wifi\" type=\"text\" placeholder=\"Password\"&gt;\n\u00a0\u00a0\u00a0\u00a0&lt;\/script&gt;\n&lt;\/body&gt;\n<\/pre>\n<h3>JavaScript \u4ee3\u7801<\/h3>\n<pre>\nangular.module('mySuperApp', ['ionic'])\n.controller('PopupCtrl',function($scope, $ionicPopup, $timeout) {\n\n \/\/ Triggered on a button click, or some other target\n $scope.showPopup = function() {\n   $scope.data = {}\n\n   \/\/ \u81ea\u5b9a\u4e49\u5f39\u7a97\n   var myPopup = $ionicPopup.show({\n     template: '&lt;input type=\"password\" ng-model=\"data.wifi\"&gt;',\n     title: 'Enter Wi-Fi Password',\n     subTitle: 'Please use normal things',\n     scope: $scope,\n     buttons: [\n       { text: 'Cancel' },\n       {\n         text: '&lt;b&gt;Save&lt;\/b&gt;',\n         type: 'button-positive',\n         onTap: function(e) {\n           if (!$scope.data.wifi) {\n             \/\/ \u4e0d\u5141\u8bb8\u7528\u6237\u5173\u95ed\uff0c\u9664\u975e\u8f93\u5165 wifi \u5bc6\u7801\n             e.preventDefault();\n           } else {\n             return $scope.data.wifi;\n           }\n         }\n       },\n     ]\n   });\n   myPopup.then(function(res) {\n     console.log('Tapped!', res);\n   });\n   $timeout(function() {\n      myPopup.close(); \/\/ 3\u79d2\u540e\u5173\u95ed\u5f39\u7a97\n   }, 3000);\n  };\n   \/\/  confirm \u5bf9\u8bdd\u6846\n   $scope.showConfirm = function() {\n     var confirmPopup = $ionicPopup.confirm({\n       title: 'Consume Ice Cream',\n       template: 'Are you sure you want to eat this ice cream?'\n     });\n     confirmPopup.then(function(res) {\n       if(res) {\n         console.log('You are sure');\n       } else {\n         console.log('You are not sure');\n       }\n     });\n   };\n\n   \/\/  alert\uff08\u8b66\u544a\uff09 \u5bf9\u8bdd\u6846\n   $scope.showAlert = function() {\n     var alertPopup = $ionicPopup.alert({\n       title: 'Don\\'t eat that!',\n       template: 'It might taste good'\n     });\n     alertPopup.then(function(res) {\n       console.log('Thank you for not eating my delicious ice cream cone');\n     });\n   };\n});\n<\/pre>\n<p><a href=\"\/try\/tryit.php?filename=ionic_ionicpopup\" target=\"_blank\"><button class=\"btn example-btn\">\u5c1d\u8bd5\u4e00\u4e0b \u00bb<\/button><\/a><\/p>\n<\/p><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">ionic \u5bf9\u8bdd\u6846 $ionicPopup ionic \u5bf9\u8bdd\u6846\u670d\u52a1\u5141\u8bb8\u7a0b\u5e8f\u521b\u5efa\u3001\u663e\u793a\u5f39\u51fa\u7a97&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=749\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,26],"tags":[43,72,73,93],"class_list":["post-749","post","type-post","status-publish","format-standard","hentry","category-hybrid","category-mobile","tag-angular","tag-hybrid","tag-ionic","tag-mobile","zoom-theme-has-thumb"],"_links":{"self":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=749"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/749\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}