【问题标题】:How to set Default page in Angular如何在 Angular 中设置默认页面
【发布时间】:2014-12-06 11:18:57
【问题描述】:

当我使用以下 URL 请求链接时出现错误:http://xxx:46630/http://crmbyzaid.azurewebsites.net/

但是当我添加带有 URL 的 '/index.html' 时效果很好。现在我想在我请求时设置我的部分页面“app/dashboard/dashboard.html”的默认呈现http://crmbyzaid.azurewebsites.net/

我的config-route.js代码是

function routeConfigurator($routeProvider, routes) {

    routes.forEach(function (r) {
        $routeProvider.when(r.url, r.config);
    });
    $routeProvider.otherwise({ redirectTo: '/' });
}
function getRoutes() {
    return [
        {
            url: '/',
            config: {
                templateUrl: 'app/dashboard/dashboard.html',
                title: 'dashboard',
                settings: {
                    nav: 1,
                    content: '<i class="fa fa-dashboard"></i> Dashboard'
                }
            }
        }, {
            url: '/admin',
            config: {
                title: 'admin',
                templateUrl: 'app/admin/admin.html',
                settings: {
                    nav: 1,
                    content: '<i class="fa fa-lock"></i> Admin'
                }
            }
        }
]
}

【问题讨论】:

  • 当您尝试访问根 url 时遇到什么错误?
  • @Fedaykin 服务器在“/”应用程序中出错

标签: javascript angularjs azure url-routing hottowel


【解决方案1】:

由于 Azure 在 IIS 上运行,您需要一个 web.config 来告诉它如何处理内容。这应该可以解决您的根页面:

<configuration>
    <system.webServer>
        <rewrite>
          <rules>
            <rule name="Main Rule" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

将文件命名为 web.config 并将其保存到您的网络根目录。

希望有帮助!

【讨论】:

猜你喜欢
  • 2010-12-27
  • 1970-01-01
  • 2018-08-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多