Q. 利用 ng-view 與 $routeProvider 建立 Single Web Application
- 如果要使用
locationProvider.html5Mode(true)
, 則需要在 index.html中包含<base href="/">
<li class="active"><a href="home">Home</a></li>
給定一個連結到 http://localhost:3000/home<div ng-view></div>
指定插入點$routeProvider.when()
建立routing機制
Q. If you want multiple views in one page
choosing angular-ui-router (新方法)
ui-sref
to point to a certain state of your application<div ui-view></div>
THIS IS WHERE WE WILL INJECT OUR CONTENT$stateProvider
to purely focus on managing State and corresponding route- it supports nested views. (參考partial-home.html,
ui-sref=".list"
及ui-sref=".paragraph"
那邊的用法, 對應script.js中的state 的 routing 規則) - it supports multiple views in one state. (參考partial-about.html, 有兩個ui-views, 一個叫columnOne, 一個叫columnTwo, 對應script.js中的
columnOne@about
及columnTwo@about
)- viewName@stateName
Q. ui-router resolve
The whole point of resolve is that it runs before controller initialization so that you can inject and directly access the resolved items in your scope. (在controller初始化前做一些事, 並把參數傳入controller)