UI-Router嵌套路由中断页面刷新

时间:2017-04-26 14:58:23

标签: angularjs angular-ui-router

我希望能够在加载标签时刷新我的Angular应用程序页面,加载我实现了以下内容的标签:

  .state('MyTemplate.Tabs.Tab',
        {
            url: '/tab',
            views: {
                'container@': {
                    templateUrl: 'App/Views/Tabs.html'
                },
                'tabs-views@': {
                    templateUrl: 'App/Views/tab.html'
                }
            }
        })

当我单击我的选项卡链接并使用它的控件加载视图时,这非常有用,但是当我刷新页面时,它会重新加载,它会尝试加载网站的根目录并且爆炸。

我尝试欺骗它但没有成功:

  .state('MyTemplate.Tabs.Tab2',
        {
            url: 'tabs/tab',
            views: {
                'container@': {
                    templateUrl: 'App/Views/Tabs.html'
                },
                'tabs-views@': {
                    templateUrl: 'App/Views/tab.html'
                }
            }
        })

任何帮助都将不胜感激。

使用州更新:

.state('MyTemplate',
{
    url: '',
    abstract: true,
    views: {
        'header': {
            templateUrl: 'App/SharedViews/header.html'
        },
        'footer': {
            templateUrl: 'App/SharedViews/footer.html'
        }
    }
})

.state('MyTemplate.Tabs',
        {
            url: '/tabs',
            views: {
                'container@': {
                    templateUrl: 'App/Views/Tabs.html'
                }
            }
        })

1 个答案:

答案 0 :(得分:0)

所以我相信您可以尝试使用以下内容配置IIS 10:

<rewrite>  
  <rules>  
    <rule name="Imported Rule 1" stopProcessing="true">  
      <match url="^(.*)$" ignoreCase="false" />  
      <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />  
    </rule>  
  </rules>  
</rewrite>  

在你的web.config中(在configuration / system.webServer内部等):

另见Symlink created with mklink not working with IIS7.5 -- Windows 7

重写HTML5历史记录规则(apache示例)

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^(js|css|img|svc)($|/) - [L]
RewriteRule ^(.*)$ index.html [L]
相关问题