当然,即使努力了也没做成,至少你也有收获,因为你知道自己以后可以避开这个坑。

这是一个"IO"开关,请看效果图和代码,下一节,说明,数据交换

Index HTML Code

<!DOCTYPE html>
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title> <link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet"> <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
--> <!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script> <!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script> <!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body> <ion-nav-bar class="bar-positive nav-title-slide-ios7">
<ion-nav-back-button class="button-icon ion-arrow-left-c">
</ion-nav-back-button>
</ion-nav-bar> <ion-nav-view animation="slide-left-right"></ion-nav-view> <script id="templates/sign-in.html" type="text/ng-template">
<ion-view title="登录">
<ion-content>
<div class="list">
<label class="item item-input">
<span class="input-label">用户名</span>
<input type="text" ng-model="user.username">
</label>
<label class="item item-input">
<span class="input-label">密 码</span>
<input type="password" ng-model="user.password">
</label>
</div>
<div class="padding">
<button class="button button-block button-positive" ng-click="signIn(user)">
立即登录
</button>
<p class="text-center">
<a href="#/forgot-password">找回密码</a>
</p>
</div>
</ion-content>
</ion-view>
</script> <script id="templates/forgot-password.html" type="text/ng-template">
<ion-view title="找回密码">
<ion-content padding="true">
<p>放弃是经线,坚持是纬线</p>
<p>没有一个谷底不可逾越</p>
<p>
返回 <a href="#/sign-in">登录</a>.
</p>
</ion-content>
</ion-view>
</script> <script id="templates/tabs.html" type="text/ng-template">
<ion-view>
<ion-tabs class="tabs-icon-top tabs-positive"> <ion-tab title="首页" icon="ion-home" href="#/tab/home">
<ion-nav-view name="home-tab"></ion-nav-view>
</ion-tab> <ion-tab title="关于" icon="ion-ios7-information" href="#/tab/about">
<ion-nav-view name="about-tab"></ion-nav-view>
</ion-tab> <ion-tab title="退出" icon="ion-log-out" href="#/sign-in">
</ion-tab> </ion-tabs>
</ion-view>
</script> <script id="templates/home.html" type="text/ng-template">
<ion-view title="首页">
<ion-content> <div class="list"> <div class="item item-divider">
设置
</div> <ion-toggle ng-repeat="item in settingsList"
ng-model="item.checked"
ng-checked="item.checked">
{{ item.text }}
</ion-toggle> <div class="item">
<pre ng-bind="settingsList | json"></pre>
</div> <div class="item item-divider">
消息通知
</div> <ion-toggle ng-model="pushNotification.checked"
ng-change="pushNotificationChange()">
是否推送消息
</ion-toggle> <div class="item">
<pre ng-bind="pushNotification | json"></pre>
</div> <ion-toggle toggle-class="toggle-assertive"
ng-model="emailNotification"
ng-true-value="{夜间模式}"
ng-false-value="{正常模式}">
模式调整
</ion-toggle> <div class="item">
<pre ng-bind="emailNotification | json"></pre>
</div> </div> </ion-content>
</ion-view>
</script> <script id="templates/facts.html" type="text/ng-template">
<ion-view title="生活圈">
<ion-content padding="true">
<h3>如果你比你身边的绝大多数人都强,那你该换朋友圈了</h3>
<p>若非青春苦短,谁会想来日方长</p>
<p>若非青春苦短,谁会想来日方长</p>
<p>
<a class="button icon ion-home" href="#/tab/home">首页</a>
<a class="button icon icon-right ion-chevron-right" href="#/tab/facts2">关于</a>
</p>
</ion-content>
</ion-view>
</script> <script id="templates/facts2.html" type="text/ng-template">
<ion-view title="关于">
<ion-content padding="true">
<h3>如果你比你身边的绝大多数人都强,那你该换朋友圈了</h3>
<p>若非青春苦短,谁会想来日方长</p>
<p>若非青春苦短,谁会想来日方长</p>
<a class="button icon ion-home" href="#/tab/home"> 首页</a>
<a class="button icon ion-chevron-left" href="#/tab/facts"> 生活圈</a>
</p>
</ion-content>
</ion-view>
</script> <script id="templates/about.html" type="text/ng-template">
<ion-view title="关于">
<ion-content padding="true">
<h3>如果你比你身边的绝大多数人都强,那你该换朋友圈了</h3>
<p>若非青春苦短,谁会想来日方长</p>
<p>若非青春苦短,谁会想来日方长</p>
<p>
<a class="button icon icon-right ion-chevron-right" href="#/tab/navstack">关于</a>
</p>
</ion-content>
</ion-view>
</script> <script id="templates/nav-stack.html" type="text/ng-template">
<ion-view title="其它">
<ion-content padding="true">
<p><img src="http://ionicframework.com/img/diagrams/tabs-nav-stack.png" style="width:100%"></p>
</ion-content>
</ion-view>
</script> </body>
</html>

App Js Code

angular.module('ionicApp', ['ionic'])

.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider
.state('signin', {
url: '/sign-in',
templateUrl: 'templates/sign-in.html',
controller: 'SignInCtrl'
})
.state('forgotpassword', {
url: '/forgot-password',
templateUrl: 'templates/forgot-password.html'
})
.state('tabs', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
.state('tabs.home', {
url: '/home',
views: {
'home-tab': {
templateUrl: 'templates/home.html',
controller: 'HomeTabCtrl'
}
}
})
.state('tabs.facts', {
url: '/facts',
views: {
'home-tab': {
templateUrl: 'templates/facts.html'
}
}
})
.state('tabs.facts2', {
url: '/facts2',
views: {
'home-tab': {
templateUrl: 'templates/facts2.html'
}
}
})
.state('tabs.about', {
url: '/about',
views: {
'about-tab': {
templateUrl: 'templates/about.html'
}
}
})
.state('tabs.navstack', {
url: '/navstack',
views: {
'about-tab': {
templateUrl: 'templates/nav-stack.html'
}
}
})
.state('tabs.contact', {
url: '/contact',
views: {
'contact-tab': {
templateUrl: 'templates/contact.html'
}
}
}); $urlRouterProvider.otherwise('/sign-in'); }) .controller('SignInCtrl', function($scope, $state) { $scope.settingsList = [
{ text: "Wireless", checked: true },
{ text: "GPS", checked: false },
{ text: "Bluetooth", checked: false }
]; $scope.pushNotificationChange = function() {
console.log('Push Notification Change', $scope.pushNotification.checked);
}; $scope.pushNotification = { checked: true };
$scope.emailNotification = 'Subscribed'; $scope.signIn = function(user) {
console.log('Sign-In', user);
$state.go('tabs.home');
}; }) .controller('HomeTabCtrl', function($scope) {
console.log('HomeTabCtrl');
});

快乐学习 Ionic Framework+PhoneGap 手册1-5 {IO开关}的更多相关文章

  1. 快乐学习 Ionic Framework+PhoneGap 手册1-1{创建APP项目}

    快乐学习 Ionic Framework+PhoneGap 手册1-1 * 前提必须安装 Node.js,安装PhoneGap,搭建Android开发环境,建议使用真机调试 {1.1}= 创建APP项 ...

  2. 快乐学习 Ionic Framework+PhoneGap 手册1-4 {登录页面}

    编程的快乐和乐趣,来自于能成功运行程序并运用到项目中 有了面板然后加个登录页面,请看效果图和代码 Index HTML Code <!DOCTYPE html> <html ng-a ...

  3. 快乐学习 Ionic Framework+PhoneGap 手册1-3 {面板切换}

    编程的快乐和乐趣,来自于能成功运行程序并运用到项目中,会在后面案例,实际运用到项目当中与数据更新一起说明 从面板切换开始,请看效果图和代码,这只是一个面板切换的效果 Index HTML Code & ...

  4. 快乐学习 Ionic Framework+PhoneGap 手册1-2{介绍Header,Content,Footer的使用}

    *先运行第一个简单的APP,介绍Header,Content,Footer的使用 {2.1}运行一个简单的APP,效果如下 {2.2}Header代码 <ion-header-bar class ...

  5. 案例:1 Ionic Framework+AngularJS+ASP.NET MVC WebApi Jsonp 移动开发

    落叶的庭院扫的一干二净之后,还要轻轻把树摇一下,抖落几片叶子,这才是Wabi Sabi的境界. 介绍:Ionic是移动框架,angularjs这就不用说了,ASP.Net MVC WebApi提供数据 ...

  6. 170多个Ionic Framework学习资源(转载)

    在Ionic官网找到的学习资源:http://blog.ionic.io/learning-ionic-in-your-living-room/ 网上的文章比较多,但是很多时候我们很难找到自己需要的. ...

  7. Wijmo 5 + Ionic Framework之:费用跟踪 App

    Wijmo 5 + Ionic Framework之:费用跟踪 App 费用跟踪应用采用了Wijmo5和Ionic Framework创建,目的是构建一个hybird app. 我们基于<Mob ...

  8. Mobile first! Wijmo 5 + Ionic Framework之:费用跟踪 App

    费用跟踪应用采用了Wijmo5和Ionic Framework创建,目的是构建一个hybird app. 我们基于<Mobile first! Wijmo 5 + Ionic Framework ...

  9. Ionic Framework 4 介绍

    Ionic Framework 4是一个开源UI工具包,用于使用Web技术(HTML,CSS和JavaScript)构建高性能的高质量移动和桌面应用程序.Ionic Framework专注于前端用户体 ...

随机推荐

  1. [浪风转载]Jquery取得iframe中元素的几种方法

    iframe在复合文档中经常用到,利用jquery操作iframe可以大幅提高效率,这里收集一些基本操作 DOM方法:父窗口操作IFRAME:window.frames["iframeSon ...

  2. lumen 单元测试

    laravel学院:http://laravelacademy.org/post/238.html 简书:https://www.jianshu.com/p/d8b3ac2c4623 问题解决:htt ...

  3. JDK的命令具体解释操作

    JDK的命令具体解释1 rmic 功能说明: rmic 为远程对象生成 stub 和 skeleton. 语法: rmic [ options ] package-qualified-class-na ...

  4. TLE之前,没有一个节点叫失败!!!

    我想我十八年来记忆最深刻的夜晚,大概便是在吉林大学燥热的宿舍里,穿着橘黄色的短袖,努力咽下大口大口的雪碧.那天晚上我仰躺在吉大热得几乎不能入眠的床板上,一动不动,看夏夜里打不尽的蚊子在惨白的天花板下飞 ...

  5. D - Find a way

    D - Find a way Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Desc ...

  6. EasyNVR对接EasyCloud视频云平台进行云端录像

    EasyCloud视频云平台是一套能够接入各种类型流,进行统一的设备管理.直播.录像.回放的视频平台,同时,EasyCloud视频云平台集成了云端运维功能,在云端就可以直接维护和控制各个现场的软件运行 ...

  7. puppeteer,webdriverio, chrome webdriver

    http://www.r9it.com/20171106/puppeteer.html Puppeteer 至少需要 Node v6.4.0,如要使用 async / await,只有 Node v7 ...

  8. JavaScript遍历IP段内所有IP

    思路:将两个IP转换为数字进行比较,小的那个慢慢加一,直到变成大的那个IP所转换的数字,将这其中的数字再转换为IP地址即为IP段内所有的IP. //IP转数字 function ip2int(ip) ...

  9. Centos之常见目录作用介绍(九)

    我们先切换到系统根目录 / 看看根目录下有哪些目录 [root@localhost ~]# cd / [root@localhost /]# ls bin   dev  home  lib64  mn ...

  10. hbase shell编码显示中文

    最近测试hbase shell,碰到个中文显示编码问题,最后通过Python解决了问题,具体操作如下: hbase(main):015:0* scan 'fr_test_hbase:test_log1 ...