├── .gitignore
├── README.md
├── config.xml
├── gif
├── 1.gif
├── 2.gif
└── events.gif
├── ionic.config.json
├── package-lock.json
├── package.json
├── resources
├── README.md
├── android
│ ├── icon
│ │ ├── drawable-hdpi-icon.png
│ │ ├── drawable-ldpi-icon.png
│ │ ├── drawable-mdpi-icon.png
│ │ ├── drawable-xhdpi-icon.png
│ │ ├── drawable-xxhdpi-icon.png
│ │ └── drawable-xxxhdpi-icon.png
│ └── splash
│ │ ├── drawable-land-hdpi-screen.png
│ │ ├── drawable-land-ldpi-screen.png
│ │ ├── drawable-land-mdpi-screen.png
│ │ ├── drawable-land-xhdpi-screen.png
│ │ ├── drawable-land-xxhdpi-screen.png
│ │ ├── drawable-land-xxxhdpi-screen.png
│ │ ├── drawable-port-hdpi-screen.png
│ │ ├── drawable-port-ldpi-screen.png
│ │ ├── drawable-port-mdpi-screen.png
│ │ ├── drawable-port-xhdpi-screen.png
│ │ ├── drawable-port-xxhdpi-screen.png
│ │ └── drawable-port-xxxhdpi-screen.png
├── icon.png
├── ios
│ ├── icon
│ │ ├── icon-1024.png
│ │ ├── icon-40.png
│ │ ├── icon-40@2x.png
│ │ ├── icon-40@3x.png
│ │ ├── icon-50.png
│ │ ├── icon-50@2x.png
│ │ ├── icon-60.png
│ │ ├── icon-60@2x.png
│ │ ├── icon-60@3x.png
│ │ ├── icon-72.png
│ │ ├── icon-72@2x.png
│ │ ├── icon-76.png
│ │ ├── icon-76@2x.png
│ │ ├── icon-83.5@2x.png
│ │ ├── icon-small.png
│ │ ├── icon-small@2x.png
│ │ ├── icon-small@3x.png
│ │ ├── icon.png
│ │ └── icon@2x.png
│ └── splash
│ │ ├── Default-568h@2x~iphone.png
│ │ ├── Default-667h.png
│ │ ├── Default-736h.png
│ │ ├── Default-Landscape-736h.png
│ │ ├── Default-Landscape@2x~ipad.png
│ │ ├── Default-Landscape@~ipadpro.png
│ │ ├── Default-Landscape~ipad.png
│ │ ├── Default-Portrait@2x~ipad.png
│ │ ├── Default-Portrait@~ipadpro.png
│ │ ├── Default-Portrait~ipad.png
│ │ ├── Default@2x~iphone.png
│ │ ├── Default@2x~universal~anyany.png
│ │ └── Default~iphone.png
└── splash.png
├── src
├── app
│ ├── app.component.ts
│ ├── app.html
│ ├── app.module.ts
│ ├── app.scss
│ └── main.ts
├── assets
│ ├── icon
│ │ └── favicon.ico
│ └── imgs
│ │ └── logo.png
├── index.html
├── manifest.json
├── pages
│ ├── home
│ │ ├── home.html
│ │ ├── home.scss
│ │ └── home.ts
│ ├── lazy-load
│ │ ├── lazy-load.html
│ │ ├── lazy-load.module.ts
│ │ ├── lazy-load.scss
│ │ └── lazy-load.ts
│ ├── net
│ │ ├── net.html
│ │ ├── net.module.ts
│ │ ├── net.scss
│ │ └── net.ts
│ └── normal-load
│ │ ├── normal-load.html
│ │ ├── normal-load.scss
│ │ └── normal-load.ts
├── providers
│ └── http
│ │ └── http.ts
├── service-worker.js
└── theme
│ └── variables.scss
├── tsconfig.json
└── tslint.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Specifies intentionally untracked files to ignore when using Git
2 | # http://git-scm.com/docs/gitignore
3 |
4 | *~
5 | *.sw[mnpcod]
6 | *.log
7 | *.tmp
8 | *.tmp.*
9 | log.txt
10 | *.sublime-project
11 | *.sublime-workspace
12 | .vscode/
13 | npm-debug.log*
14 |
15 | .idea/
16 | .sourcemaps/
17 | .sass-cache/
18 | .tmp/
19 | .versions/
20 | coverage/
21 | dist/
22 | node_modules/
23 | tmp/
24 | temp/
25 | hooks/
26 | platforms/
27 | plugins/
28 | plugins/android.json
29 | plugins/ios.json
30 | www/
31 | $RECYCLE.BIN/
32 |
33 | .DS_Store
34 | Thumbs.db
35 | UserInterfaceState.xcuserstate
36 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## 背景
2 | 上一年使用 `ionic` 做了一个项目,花费了很多的精力,从一窍不通,到开发自如,中间也是踩了不少坑,回头来看,非常感慨。
3 |
4 | 后来在 `SegmentFault`上回答了 `ionic` 新手问的很多初级问题,想起了当时自己无人指导的痛苦,心中升起写一个 `ionic` 入门手册的念头,于是就有了这个项目。
5 | 中文名就叫 `手摸手带你入门ionic3`,所有的内容都在issue中,方便大家评论。
6 |
7 | 项目的目标是写一个东半球第二简单易懂的 `ionic` 入门指南,使有 `web` 开发经验的小伙伴可以很快上手 `ionic` 开发,配合我[Blog](https://github.com/JerryMissTom/Blog/issues)
8 | 中的踩坑集锦,可以节省大家的很多时间。
9 |
10 | `ionic` 的优点很明显,就是写起来快,`write once,run anywhere`。除了少数需要针对不同平台特性的适配外,其他的一套代码搞定,使用不同的打包命令,
11 | 可以生成在 `Android` 和 `iOS`上运行的APP。
12 |
13 | `ionic` 的缺点也是很明显,性能,还是性能,`Android 4.4` 以下就别使用此框架了。安卓低端机上比较卡顿,用户体验不是很好。
14 | ## 目录
15 | 我打算按照下面的主题来介绍,过程中可能会有调整。
16 | * ionic介绍
17 | * 环境配置
18 | * 新建项目
19 | * 数据和事件绑定
20 | * 样式绑定
21 | * 界面跳转
22 | * 生命周期
23 | * 主题风格
24 | * Events广播
25 | * 网络请求
26 | * 平台适配
27 | * 打包准备
28 | * ...
29 | ## 用法
30 | 我将讲解过程中的代码按照主题发布至本仓库,大家可下载项目运行并根据提交记录对比查看相关代码
31 |
32 | 项目安装运行步骤:
33 | ```
34 | git clone https://github.com/JerryMissTom/ionic3-handbook.git
35 | npm install
36 | ionic serve
37 | ```
38 |
--------------------------------------------------------------------------------
/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | MyApp
4 | An awesome Ionic/Cordova app.
5 | Ionic Framework Team
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/gif/1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/gif/1.gif
--------------------------------------------------------------------------------
/gif/2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/gif/2.gif
--------------------------------------------------------------------------------
/gif/events.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/gif/events.gif
--------------------------------------------------------------------------------
/ionic.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "awesomeProject",
3 | "app_id": "",
4 | "type": "ionic-angular",
5 | "integrations": {
6 | "cordova": {}
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "awesomeProject",
3 | "version": "0.0.1",
4 | "author": "Ionic Framework",
5 | "homepage": "http://ionicframework.com/",
6 | "private": true,
7 | "scripts": {
8 | "clean": "ionic-app-scripts clean",
9 | "build": "ionic-app-scripts build",
10 | "lint": "ionic-app-scripts lint",
11 | "ionic:build": "ionic-app-scripts build",
12 | "ionic:serve": "ionic-app-scripts serve"
13 | },
14 | "dependencies": {
15 | "@angular/common": "5.0.0",
16 | "@angular/compiler": "5.0.0",
17 | "@angular/compiler-cli": "5.0.0",
18 | "@angular/core": "5.0.0",
19 | "@angular/forms": "5.0.0",
20 | "@angular/http": "5.0.0",
21 | "@angular/platform-browser": "5.0.0",
22 | "@angular/platform-browser-dynamic": "5.0.0",
23 | "@ionic-native/app-version": "^4.7.0",
24 | "@ionic-native/core": "4.3.2",
25 | "@ionic-native/splash-screen": "4.3.2",
26 | "@ionic-native/status-bar": "4.3.2",
27 | "@ionic/storage": "2.1.3",
28 | "cordova-android": "^6.2.3",
29 | "cordova-ios": "^4.4.0",
30 | "cordova-plugin-app-version": "^0.1.9",
31 | "cordova-plugin-device": "^1.1.4",
32 | "cordova-plugin-ionic-webview": "^1.2.0",
33 | "cordova-plugin-splashscreen": "^4.0.3",
34 | "cordova-plugin-whitelist": "^1.3.1",
35 | "ionic-angular": "3.9.2",
36 | "ionic-plugin-keyboard": "^2.2.1",
37 | "ionicons": "3.0.0",
38 | "rxjs": "5.5.2",
39 | "sw-toolbox": "3.6.0",
40 | "ws": "^3.3.2",
41 | "zone.js": "0.8.18"
42 | },
43 | "devDependencies": {
44 | "@ionic/app-scripts": "3.1.0",
45 | "typescript": "2.4.2"
46 | },
47 | "description": "An Ionic project",
48 | "cordova": {
49 | "plugins": {
50 | "cordova-plugin-app-version": {},
51 | "cordova-plugin-device": {},
52 | "cordova-plugin-ionic-webview": {},
53 | "cordova-plugin-splashscreen": {},
54 | "cordova-plugin-whitelist": {},
55 | "ionic-plugin-keyboard": {}
56 | },
57 | "platforms": [
58 | "android",
59 | "ios"
60 | ]
61 | }
62 | }
--------------------------------------------------------------------------------
/resources/README.md:
--------------------------------------------------------------------------------
1 | These are Cordova resources. You can replace icon.png and splash.png and run
2 | `ionic cordova resources` to generate custom icons and splash screens for your
3 | app. See `ionic cordova resources --help` for details.
4 |
5 | Cordova reference documentation:
6 |
7 | - Icons: https://cordova.apache.org/docs/en/latest/config_ref/images.html
8 | - Splash Screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/
9 |
--------------------------------------------------------------------------------
/resources/android/icon/drawable-hdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/icon/drawable-hdpi-icon.png
--------------------------------------------------------------------------------
/resources/android/icon/drawable-ldpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/icon/drawable-ldpi-icon.png
--------------------------------------------------------------------------------
/resources/android/icon/drawable-mdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/icon/drawable-mdpi-icon.png
--------------------------------------------------------------------------------
/resources/android/icon/drawable-xhdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/icon/drawable-xhdpi-icon.png
--------------------------------------------------------------------------------
/resources/android/icon/drawable-xxhdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/icon/drawable-xxhdpi-icon.png
--------------------------------------------------------------------------------
/resources/android/icon/drawable-xxxhdpi-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/icon/drawable-xxxhdpi-icon.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-hdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-land-hdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-ldpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-land-ldpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-mdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-land-mdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-xhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-land-xhdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-xxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-land-xxhdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-land-xxxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-land-xxxhdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-hdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-port-hdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-ldpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-port-ldpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-mdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-port-mdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-xhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-port-xhdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-xxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-port-xxhdpi-screen.png
--------------------------------------------------------------------------------
/resources/android/splash/drawable-port-xxxhdpi-screen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/android/splash/drawable-port-xxxhdpi-screen.png
--------------------------------------------------------------------------------
/resources/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/icon.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-1024.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-40.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-40@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-40@3x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-50.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-50@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-50@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-60.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-60@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-60@3x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-72.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-72@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-72@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-76.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-76@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-83.5@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-small.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-small@2x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon-small@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon-small@3x.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon.png
--------------------------------------------------------------------------------
/resources/ios/icon/icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/icon/icon@2x.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-568h@2x~iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default-568h@2x~iphone.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-667h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default-667h.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-736h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default-736h.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Landscape-736h.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default-Landscape-736h.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Landscape@2x~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default-Landscape@2x~ipad.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Landscape@~ipadpro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default-Landscape@~ipadpro.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Landscape~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default-Landscape~ipad.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Portrait@2x~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default-Portrait@2x~ipad.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Portrait@~ipadpro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default-Portrait@~ipadpro.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default-Portrait~ipad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default-Portrait~ipad.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default@2x~iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default@2x~iphone.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default@2x~universal~anyany.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default@2x~universal~anyany.png
--------------------------------------------------------------------------------
/resources/ios/splash/Default~iphone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/ios/splash/Default~iphone.png
--------------------------------------------------------------------------------
/resources/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/resources/splash.png
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { Platform } from 'ionic-angular';
3 | import { StatusBar } from '@ionic-native/status-bar';
4 | import { SplashScreen } from '@ionic-native/splash-screen';
5 |
6 | import { HomePage } from '../pages/home/home';
7 | @Component({
8 | templateUrl: 'app.html'
9 | })
10 | export class MyApp {
11 | rootPage:any = HomePage;
12 |
13 | constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
14 | platform.ready().then(() => {
15 | // Okay, so the platform is ready and our plugins are available.
16 | // Here you can do any higher level native things you might need.
17 | statusBar.styleDefault();
18 | splashScreen.hide();
19 | });
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/src/app/app.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { ErrorHandler, NgModule } from '@angular/core';
3 | import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
4 | import { SplashScreen } from '@ionic-native/splash-screen';
5 | import { StatusBar } from '@ionic-native/status-bar';
6 | import { HttpClientModule } from '@angular/common/http';
7 | import { MyApp } from './app.component';
8 | import { HomePage } from '../pages/home/home';
9 | import { NormalLoadPage } from '../pages/normal-load/normal-load';
10 | import { HttpProvider } from '../providers/http/http';
11 |
12 | @NgModule({
13 | declarations: [
14 | MyApp,
15 | HomePage,
16 | NormalLoadPage
17 | ],
18 | imports: [
19 | HttpClientModule,
20 | BrowserModule,
21 | IonicModule.forRoot(MyApp, {
22 | backButtonIcon:'ios-arrow-back',
23 | backButtonText: '',
24 | mode: 'ios'
25 | })
26 | ],
27 | bootstrap: [IonicApp],
28 | entryComponents: [
29 | MyApp,
30 | HomePage,
31 | NormalLoadPage
32 | ],
33 | providers: [
34 | HttpProvider,
35 | StatusBar,
36 | SplashScreen,
37 | {provide: ErrorHandler, useClass: IonicErrorHandler},
38 |
39 | ]
40 | })
41 | export class AppModule {}
42 |
--------------------------------------------------------------------------------
/src/app/app.scss:
--------------------------------------------------------------------------------
1 |
2 |
3 | $screen_width: 720;
4 | @function rem($px) {
5 | @return ($px / $screen_width) * 100vw;
6 | }
7 |
8 | .btn-primary {
9 | background: powderblue;
10 | color: white;
11 | width: rem(360);
12 | height:rem(50);
13 | margin: rem(5);
14 | font-size: rem(12);
15 | }
--------------------------------------------------------------------------------
/src/app/main.ts:
--------------------------------------------------------------------------------
1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2 |
3 | import { AppModule } from './app.module';
4 |
5 | platformBrowserDynamic().bootstrapModule(AppModule);
6 |
--------------------------------------------------------------------------------
/src/assets/icon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/src/assets/icon/favicon.ico
--------------------------------------------------------------------------------
/src/assets/imgs/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JerryMissTom/ionic3-handbook/fa36591d9941068f36ee9903e3973b54809fe104/src/assets/imgs/logo.png
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ionic App
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/src/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Ionic",
3 | "short_name": "Ionic",
4 | "start_url": "index.html",
5 | "display": "standalone",
6 | "icons": [{
7 | "src": "assets/imgs/logo.png",
8 | "sizes": "512x512",
9 | "type": "image/png"
10 | }],
11 | "background_color": "#4e8ef7",
12 | "theme_color": "#4e8ef7"
13 | }
--------------------------------------------------------------------------------
/src/pages/home/home.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 首页
5 |
6 |
7 |
8 |
9 |
10 |
11 | {{2+3}}
12 | {{title}}
13 |
14 |
15 | 看得到我
16 | 看不到我
17 |
18 | 0" [style.font-size.em]="isShown ? 2 : 1">下面是数组,长度为{{names.length}}
19 |
20 | -
21 | {{ i+item }}
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/pages/home/home.scss:
--------------------------------------------------------------------------------
1 | page-home {
2 | .alert {
3 | color: red
4 | }
5 | }
--------------------------------------------------------------------------------
/src/pages/home/home.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { NavController, Events } from 'ionic-angular';
3 | import { NormalLoadPage } from '../normal-load/normal-load';
4 |
5 | @Component({selector: 'page-home', templateUrl: 'home.html'})
6 | export class HomePage {
7 |
8 | title : string = '';
9 | isShown : boolean = true;
10 | names : string[] = ['张三', '李四', '王二麻子'];
11 |
12 | constructor(public navCtrl : NavController, public events:Events) {
13 | console.log("HomePage constructor");
14 | }
15 |
16 | onChangeTitle() {
17 | console.log('HomePage');
18 | this.title = "Home";
19 | }
20 |
21 | toLazyLoadPage() {
22 | this.navCtrl.push('LazyLoadPage', {
23 | name: 'ionic',
24 | age: 18
25 | });
26 | }
27 |
28 | toNormalLoadPage(){
29 | this.navCtrl.push(NormalLoadPage, {
30 | name: 'handbook',
31 | age: 20
32 | });
33 | }
34 |
35 | toNetPage(){
36 | this.navCtrl.push('NetPage');
37 | }
38 |
39 | ionViewDidLoad() {
40 | console.log('HomePage ionViewDidLoad');
41 | this.events.subscribe('changeTitle',(title)=>{
42 | this.title=title;
43 | });
44 | }
45 |
46 | ionViewWillEnter() {
47 | console.log('HomePage ionViewWillEnter');
48 | }
49 |
50 | ionViewDidEnter() {
51 | console.log('HomePage ionViewDidEnter');
52 | }
53 |
54 | ionViewWillLeave() {
55 | console.log('HomePage ionViewWillLeave');
56 | }
57 |
58 | ionViewDidLeave() {
59 | console.log('HomePage ionViewDidLeave');
60 | }
61 |
62 | ionViewWillUnload() {
63 | console.log('HomePage ionViewWillUnload');
64 | this.events.unsubscribe('changeTitle',()=>{
65 | console.log('取消订阅changeTitle事件');
66 | });
67 | }
68 |
69 | ionViewCanEnter() {
70 | console.log('HomePage ionViewCanEnter');
71 | }
72 |
73 | ionViewCanLeave() {
74 | console.log('HomePage ionViewCanLeave');
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/pages/lazy-load/lazy-load.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | lazy-load
4 |
5 |
6 |
7 |
8 | name:{{name}}
9 | age:{{age}}
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/pages/lazy-load/lazy-load.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { IonicPageModule } from 'ionic-angular';
3 | import { LazyLoadPage } from './lazy-load';
4 |
5 | @NgModule({
6 | declarations: [
7 | LazyLoadPage,
8 | ],
9 | imports: [
10 | IonicPageModule.forChild(LazyLoadPage),
11 | ],
12 | })
13 | export class LazyLoadPageModule {}
14 |
--------------------------------------------------------------------------------
/src/pages/lazy-load/lazy-load.scss:
--------------------------------------------------------------------------------
1 | page-lazy-load {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/src/pages/lazy-load/lazy-load.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { IonicPage, NavController, NavParams } from 'ionic-angular';
3 | import { Events } from 'ionic-angular';
4 | @IonicPage()
5 | @Component({
6 | selector: 'page-lazy-load',
7 | templateUrl: 'lazy-load.html',
8 | })
9 | export class LazyLoadPage {
10 |
11 | name:string;
12 | age:number;
13 |
14 | constructor(public navCtrl: NavController, public navParams: NavParams, public events:Events) {
15 | this.name=this.navParams.get('name');
16 | this.age=this.navParams.get('age');
17 | }
18 |
19 | back(){
20 | this.navCtrl.pop();
21 | }
22 |
23 | sendEvent(){
24 | this.events.publish('changeTitle','ionic');
25 | }
26 |
27 | ionViewDidLoad() {
28 | console.log('ionViewDidLoad LazyLoadPage');
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/pages/net/net.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | net
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/pages/net/net.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { IonicPageModule } from 'ionic-angular';
3 | import { NetPage } from './net';
4 |
5 | @NgModule({
6 | declarations: [
7 | NetPage,
8 | ],
9 | imports: [
10 | IonicPageModule.forChild(NetPage),
11 | ],
12 | })
13 | export class NetPageModule {}
14 |
--------------------------------------------------------------------------------
/src/pages/net/net.scss:
--------------------------------------------------------------------------------
1 | page-net {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/src/pages/net/net.ts:
--------------------------------------------------------------------------------
1 | import {Component} from '@angular/core';
2 | import {IonicPage, NavController, NavParams} from 'ionic-angular';
3 | import {HttpProvider} from '../../providers/http/http';
4 |
5 | @IonicPage()
6 | @Component({selector: 'page-net', templateUrl: 'net.html'})
7 | export class NetPage {
8 |
9 | constructor(private http : HttpProvider) {}
10 |
11 | ionViewDidLoad() {
12 | this.http.get('https://api.douban.com/v2/movie/in_theaters?start=0&count=5').subscribe(success => {
13 | console.log(success)
14 | }, fail => {
15 | console.log('网络错误');
16 | });
17 | }
18 |
19 | // post用法的列子
20 | requestData() {
21 |
22 | let url = '';
23 | let request = {
24 | name: '张三'
25 | };
26 |
27 | this.http.post(url, request).subscribe(success => {
28 | console.log(success);
29 | }, fail => {
30 | console.log('网络错误');
31 | });
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/src/pages/normal-load/normal-load.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | normal-load
4 |
5 |
6 |
7 |
8 | name:{{name}}
9 | age:{{age}}
10 |
--------------------------------------------------------------------------------
/src/pages/normal-load/normal-load.scss:
--------------------------------------------------------------------------------
1 | normal-load {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/src/pages/normal-load/normal-load.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { NavController, NavParams } from 'ionic-angular';
3 |
4 | @Component({
5 | selector: 'normal-load',
6 | templateUrl: 'normal-load.html'
7 | })
8 |
9 | export class NormalLoadPage {
10 |
11 | name : string;
12 | age : number;
13 |
14 | constructor(public navCtrl : NavController, public navParams : NavParams) {
15 | // 变量初始化,获取从上一界面传过来的参数
16 | console.log("NormalLoadPage constructor");
17 | this.name = this.navParams.get('name');
18 | this.age = this.navParams.get('age');
19 | }
20 |
21 | ionViewDidLoad() {
22 | // 界面加载进来运行,并且只运行一次,在这里可以进行网络请求,订阅事件等操作
23 | console.error('NormalLoadPage ionViewDidLoad');
24 | }
25 |
26 | ionViewWillEnter() {
27 | // 当界面将要成为active的时候运行,用的比较少
28 | console.error('NormalLoadPage ionViewWillEnter');
29 | }
30 |
31 | ionViewDidEnter() {
32 | // 界面每次变成active的时候都会运行,常见的使用场景是每次进入此界面都重新从网络获取数据
33 | console.error('NormalLoadPage ionViewDidEnter');
34 | }
35 |
36 | ionViewWillLeave() {
37 | // 界面将要离开的时候
38 | console.error('NormalLoadPage ionViewWillLeave');
39 | }
40 |
41 | ionViewDidLeave() {
42 | // 界面已经离开的时候,不在是active
43 | console.error('NormalLoadPage ionViewWillLeave');
44 | }
45 |
46 | ionViewWillUnload() {
47 | // 当界面被销毁的时候,这儿可以执行取消订阅等操作
48 | console.error('NormalLoadPage ionViewWillUnload');
49 | }
50 |
51 | ionViewCanEnter() {
52 | // 通过返回true或者false来决定是否可以进入此界面,返回true是可以
53 | console.error('NormalLoadPage ionViewCanEnter');
54 | }
55 |
56 | ionViewCanLeave() {
57 | // 通过返回true或者false来决定是否可以离开此界面,返回true是可以,这儿可以进行判断数据是否提交等操作
58 | console.error('NormalLoadPage ionViewCanLeave');
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/providers/http/http.ts:
--------------------------------------------------------------------------------
1 | import {HttpClient, HttpHeaders} from '@angular/common/http';
2 | import {Injectable} from '@angular/core';
3 | import {Observable} from 'rxjs/Observable';
4 | import 'rxjs/add/operator/catch';
5 | import 'rxjs/add/observable/throw';
6 | import 'rxjs/add/operator/timeout';
7 |
8 | @Injectable()
9 | export class HttpProvider {
10 |
11 | constructor(public http : HttpClient) {}
12 |
13 | get(url) {
14 | return this.http.get(url).timeout(10000).catch(this.handlerError);
15 | }
16 |
17 | post(url, request) {
18 | const body : string = JSON.stringify(request);
19 | const httpOptions = {
20 | headers: new HttpHeaders({'Content-Type': 'application/json'})
21 | };
22 | return this.http.post(url, body, httpOptions).timeout(10000).catch(this.handlerError);
23 | }
24 |
25 | private handlerError(error : Response | any) {
26 | const body = error.json() || {};
27 | return Observable.throw(body);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/service-worker.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Check out https://googlechromelabs.github.io/sw-toolbox/ for
3 | * more info on how to use sw-toolbox to custom configure your service worker.
4 | */
5 |
6 |
7 | 'use strict';
8 | importScripts('./build/sw-toolbox.js');
9 |
10 | self.toolbox.options.cache = {
11 | name: 'ionic-cache'
12 | };
13 |
14 | // pre-cache our key assets
15 | self.toolbox.precache(
16 | [
17 | './build/main.js',
18 | './build/vendor.js',
19 | './build/main.css',
20 | './build/polyfills.js',
21 | 'index.html',
22 | 'manifest.json'
23 | ]
24 | );
25 |
26 | // dynamically cache any other local assets
27 | self.toolbox.router.any('/*', self.toolbox.fastest);
28 |
29 | // for any other requests go to the network, cache,
30 | // and then only use that cached resource if your user goes offline
31 | self.toolbox.router.default = self.toolbox.networkFirst;
32 |
--------------------------------------------------------------------------------
/src/theme/variables.scss:
--------------------------------------------------------------------------------
1 | // Ionic Variables and Theming. For more info, please see:
2 | // http://ionicframework.com/docs/theming/
3 |
4 | // Font path is used to include ionicons,
5 | // roboto, and noto sans fonts
6 | $font-path: "../assets/fonts";
7 |
8 |
9 | // The app direction is used to include
10 | // rtl styles in your app. For more info, please see:
11 | // http://ionicframework.com/docs/theming/rtl-support/
12 | $app-direction: ltr;
13 |
14 |
15 | @import "ionic.globals";
16 |
17 |
18 | // Shared Variables
19 | // --------------------------------------------------
20 | // To customize the look and feel of this app, you can override
21 | // the Sass variables found in Ionic's source scss files.
22 | // To view all the possible Ionic variables, see:
23 | // http://ionicframework.com/docs/theming/overriding-ionic-variables/
24 |
25 |
26 |
27 |
28 | // Named Color Variables
29 | // --------------------------------------------------
30 | // Named colors makes it easy to reuse colors on various components.
31 | // It's highly recommended to change the default colors
32 | // to match your app's branding. Ionic uses a Sass map of
33 | // colors so you can add, rename and remove colors as needed.
34 | // The "primary" color is the only required color in the map.
35 |
36 | $colors: (
37 | primary: #488aff,
38 | secondary: #32db64,
39 | danger: #f53d3d,
40 | light: #f4f4f4,
41 | dark: #222
42 | );
43 |
44 |
45 | // App iOS Variables
46 | // --------------------------------------------------
47 | // iOS only Sass variables can go here
48 |
49 |
50 |
51 |
52 | // App Material Design Variables
53 | // --------------------------------------------------
54 | // Material Design only Sass variables can go here
55 |
56 |
57 |
58 |
59 | // App Windows Variables
60 | // --------------------------------------------------
61 | // Windows only Sass variables can go here
62 |
63 |
64 |
65 |
66 | // App Theme
67 | // --------------------------------------------------
68 | // Ionic apps can have different themes applied, which can
69 | // then be future customized. This import comes last
70 | // so that the above variables are used and Ionic's
71 | // default are overridden.
72 |
73 | @import "ionic.theme.default";
74 |
75 |
76 | // Ionicons
77 | // --------------------------------------------------
78 | // The premium icon font for Ionic. For more info, please see:
79 | // http://ionicframework.com/docs/ionicons/
80 |
81 | @import "ionic.ionicons";
82 |
83 |
84 | // Fonts
85 | // --------------------------------------------------
86 |
87 | @import "roboto";
88 | @import "noto-sans";
89 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowSyntheticDefaultImports": true,
4 | "declaration": false,
5 | "emitDecoratorMetadata": true,
6 | "experimentalDecorators": true,
7 | "lib": [
8 | "dom",
9 | "es2015"
10 | ],
11 | "module": "es2015",
12 | "moduleResolution": "node",
13 | "sourceMap": true,
14 | "target": "es5"
15 | },
16 | "include": [
17 | "src/**/*.ts"
18 | ],
19 | "exclude": [
20 | "node_modules"
21 | ],
22 | "compileOnSave": false,
23 | "atom": {
24 | "rewriteTsconfig": false
25 | }
26 | }
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "no-duplicate-variable": true,
4 | "no-unused-variable": [
5 | true
6 | ]
7 | },
8 | "rulesDirectory": [
9 | "node_modules/tslint-eslint-rules/dist/rules"
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------