【发布时间】:2015-09-01 12:30:13
【问题描述】:
我正在学习 Pro Angular 教程。我有一个关于用角度路线解决铁路路线的问题。
我有以下代码:
$urlRouterProvider.otherwise("/products");
$stateProvider
.state('root', {
url: "/stores",
abstract: true,
template: '<ui-view/>'
})
.state('products', {
url: "/products",
templateUrl: "<%= asset_path('store/templates/productList.html') %>",
controller: "productListCtrl as plCtrl"
})
.state('checkout', {
url: "/checkout",
templateUrl: "<%= asset_path('store/templates/checkoutSummary.html') %>"
})
当我转到 localhost:3000 时,我的 url 会自动转到 /products 并显示正确的页面。但是,当我在浏览器上点击重新加载时,我得到一个 rails 错误页面,提示缺少模板产品/索引。
routes.rb
resources :stores, only: :index
get 'stores/*app', to: 'stores#index'
resources :products, only: :index
namespace :api, constraints: {format: :json}, defaults: {format: :json} do
namespace :v1 do
resources :products
end
end
root 'stores#index'
app/views/stores/index.html.slim
base href="/stores"
div ng-app="storeApp"
ui-view autoscroll="top"
【问题讨论】: