2014年10月9日 星期四

ionic routing(上)

在ionic 中的routing 是採用  Angular 中的 ngRoute來做為routing。


ionic 官方的範例 : http://codepen.io/ionic/pen/AjgEB


首先在 view 中會有一個區塊是專門來render 使用的


在config 中要 inject $stateProvider及 $urlRouterProvider,這個部份在ionic new Project 就已經都處理好了,所以也不用特別去理會它。
但以下的部份就要特別小心了,$stateProvider的state來決定route的規則
url 是指在 URL 上的規則,在下方是指Root
templateUrl 是指要找那一份template檔案,在下圖是指 intro.html的page
controller 是指template 中的控制model 的內容,以下圖是指在 IntroCtrl 的 function 內做控制。


templateUrl 可能是一個檔案位置或是 id


Controller 指定為 IntroCtrl ,在此 function 內的才能binding 到 intro.html


待續...

沒有留言:

張貼留言