{"id":740,"date":"2018-02-25T20:33:17","date_gmt":"2018-02-25T12:33:17","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/25\/ionic-%e5%88%87%e6%8d%a2%e5%bc%80%e5%85%b3%e6%93%8d%e4%bd%9c\/"},"modified":"2018-02-25T20:33:17","modified_gmt":"2018-02-25T12:33:17","slug":"ionic-%e5%88%87%e6%8d%a2%e5%bc%80%e5%85%b3%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=740","title":{"rendered":"ionic \u5207\u6362\u5f00\u5173\u64cd\u4f5c"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h1>ionic \u5207\u6362\u5f00\u5173\u64cd\u4f5c<\/h1>\n<p>\u4ee5\u4e0b\u5b9e\u4f8b\u4e2d\uff0c\u901a\u8fc7\u5207\u6362\u4e0d\u540c\u5f00\u5173 checked \u663e\u793a\u4e0d\u540c\u7684\u503c\uff0ctrue \u4e3a\u6253\u5f00\uff0cfalse \u4e3a\u5173\u95ed\u3002<\/p>\n<h3>HTML \u4ee3\u7801<\/h3>\n<pre>\n&lt;ion-header-bar class=\"bar-positive\"&gt;\n  &lt;h1 class=\"title\"&gt;\u5f00\u5173\u5207\u6362&lt;\/h1&gt;\n&lt;\/ion-header-bar&gt;\n         \n&lt;ion-content&gt;\n  \n  &lt;div class=\"list\"&gt;\n    \n    &lt;div class=\"item item-divider\"&gt; \n      Settings\n    &lt;\/div&gt;\n    \n    &lt;ion-toggle ng-repeat=\"item in settingsList\"\n                ng-model=\"item.checked\" \n                ng-checked=\"item.checked\"&gt;\n      {{ item.text }}\n    &lt;\/ion-toggle&gt;\n    \n    &lt;div class=\"item\"&gt;\n    \u00a0\u00a0\u00a0\u00a0&lt;!-- \u4f7f\u7528 pre \u6807\u7b7e\u5c55\u793a\u6548\u679c\u66f4\u7f8e\u89c2 --&gt;\n      &lt;div ng-bind=\"settingsList | json\"&gt;&lt;\/div&gt; \n    &lt;\/div&gt;\n    \n    &lt;div class=\"item item-divider\"&gt; \n      Notifications\n    &lt;\/div&gt;\n    \n    &lt;ion-toggle ng-model=\"pushNotification.checked\"\n                ng-change=\"pushNotificationChange()\"&gt;\n      Push Notifications\n    &lt;\/ion-toggle&gt;\n    \n    &lt;div class=\"item\"&gt;\n    \u00a0\u00a0\u00a0\u00a0&lt;!-- \u4f7f\u7528 pre \u6807\u7b7e\u5c55\u793a\u6548\u679c\u66f4\u7f8e\u89c2 --&gt;\n      &lt;div ng-bind=\"pushNotification | json\"&gt;&lt;\/div&gt; \n    &lt;\/div&gt;\n    \n    &lt;ion-toggle toggle-class=\"toggle-assertive\"\n                ng-model=\"emailNotification\"\n                ng-true-value=\"'Subscribed'\"\n                ng-false-value=\"'Unubscribed'\"&gt;\n      Newsletter\n    &lt;\/ion-toggle&gt;\n    \n    &lt;div class=\"item\"&gt;\n    \u00a0\u00a0\u00a0\u00a0&lt;!-- \u4f7f\u7528 pre \u6807\u7b7e\u5c55\u793a\u6548\u679c\u66f4\u7f8e\u89c2 --&gt;\n      &lt;div ng-bind=\"emailNotification | json\"&gt;&lt;\/div&gt; \n    &lt;\/div&gt;\n    \n  &lt;\/div&gt;\n  \n&lt;\/ion-content&gt;\n<\/pre>\n<p>\u7531\u4e8epre\u6807\u7b7e\u51b2\u7a81\uff0c\u5b9e\u4f8b\u4e2d\u7684 pre \u5df2\u66ff\u6362\u4e3a div\u6807\u7b7e\uff0c\u5177\u4f53\u53ef\u4ee5\u5728&#8221;\u5c1d\u8bd5\u4e00\u4e0b&#8221;\u4e2d\u67e5\u770b\u3002<\/p>\n<h3>JavaScript \u4ee3\u7801<\/h3>\n<pre>\nangular.module('ionicApp', ['ionic'])\n\n.controller('MainCtrl', function($scope) {\n\n  $scope.settingsList = [\n    { text: \"Wireless\", checked: true },\n    { text: \"GPS\", checked: false },\n    { text: \"Bluetooth\", checked: false }\n  ];\n\n  $scope.pushNotificationChange = function() {\n    console.log('Push Notification Change', $scope.pushNotification.checked);\n  };\n  \n  $scope.pushNotification = { checked: true };\n  $scope.emailNotification = 'Subscribed';\n  \n});\n<\/pre>\n<p>css \u4ee3\u7801\uff1a<\/p>\n<pre>\nbody {\n  cursor: url('http:\/\/www.runoob.com\/try\/demo_source\/finger.png'), auto;\n}\n<\/pre>\n<p><a href=\"\/try\/tryit.php?filename=ionic_ion-toggle\" target=\"_blank\"><button class=\"btn example-btn\">\u5c1d\u8bd5\u4e00\u4e0b \u00bb<\/button><\/a><\/p>\n<p>\u6548\u679c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><iframe frameborder=\"0\" height=\"400\" src=\"\/try\/demo_source\/ionic_ion-toggle.htm\"><\/iframe>\t\t\t<\/p><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">ionic \u5207\u6362\u5f00\u5173\u64cd\u4f5c \u4ee5\u4e0b\u5b9e\u4f8b\u4e2d\uff0c\u901a\u8fc7\u5207\u6362\u4e0d\u540c\u5f00\u5173 checked \u663e\u793a\u4e0d\u540c\u7684\u503c\uff0ctr&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=740\">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-740","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\/740","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=740"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/740\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}