Firebase托管中的子目录Angular应用程序

时间:2015-10-28 14:51:39

标签: angularjs angular-ui-router firebase-hosting

一直在尝试在子目录/grid中部署我的角度应用,但没有显示here

  1. 对于index.html,我已添加<base href="/grid/" />
  2. 对于firebase配置,我已经使用了

    "rewrites": [ {
        "source" : "/grid/**/*",
        "destination" : "/grid/index.html"
     } ]
    
  3. 对于角度配置,

    angular.module('columns', [
      'ui.router',
      'columns.main',
    ])
    .config(function($stateProvider, $urlRouterProvider, $locationProvider) {
       'use strict';
    
       $locationProvider.html5Mode(true);
       $urlRouterProvider.otherwise('/');
    
       $stateProvider
         .state('main', {
           url: '/',
           templateUrl: '/columns/main/main.html',
           controller: 'MainCtrl'
         });
       });
    
  4. 构建将有

     module.run(['$templateCache', function($templateCache) {
       $templateCache.put('/columns/main/main.html','<something>');
     }]);
    
  5. 如果我在本地运行它并将基本标记更改为<base href="/" />,它将正常工作。有人看到错误吗?

1 个答案:

答案 0 :(得分:1)

不确定您是否还在寻找,我在自己搜索时遇到了您的问题。

你可以在你的firebase托管(公共)目录中有一个名为“/ grid”的子文件夹,正确的重写规则是:

"rewrites": [ {
  "source" : "/grid/**",
  "destination" : "/grid/index.html"
} ]

最后没有额外的“/ *”。 在您的配置中,您似乎只为角度应用程序提供了规则,您可能还需要为角度路由器设置适当的前缀规则。

希望有所帮助:)

相关问题