1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ionic3に入門してみる~その9 Angular4チュートリアル⑦~

Posted at

ルーティング

Angular自体のルーティングはIonicでは使用しないため、Angularチュートリアルのルーティングについては割愛します。

Ionicのルーティング

Ionic2の記事ですが下記をご覧ください。
https://qiita.com/kohashi/items/f424fb5dd897fc6317c9

基本的にIonicではルーティングは不要とされているようです。

しかしもちろんそういった動作もサポートされています。
Ionic3では、IonicPageModuleを使用します!(Ionic2までと情報が混在しててなかなか難しいですが…)

例として今回は新しいサンプルを使用します。
まず下記のコマンドを実行します。

ionic start sampleApp
ionic g page second

なおsampleAppはblankとしてください。
するとこんな感じのサンプルができるはずです。
image.png

手を加えるところは多くありません。
まず最初にhome.tsを編集します。
image.png

次に、呼び出すボタンをhtmlに作成します。
image.png

手を加えるわけではありませんが、最後にsecondのページを見てみましょう。
pushしているのはsecond.tsで宣言されているSecondPageクラスだとわかります。
image.png

これを動かしてみると下記のように動きます。
test.gif

詳細は下記のDocにあります。ぜひ見てみてください。
https://ionicframework.com/docs/api/navigation/IonicPage/

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?