2017-03-01 10 views
1

ng-viewportを使用してindex.htmlにページを表示しています.HTML 5モードでは、ベースURL(例:http://localhost:86)を開くとすべてが正常に動作しています私の家や着陸ページである(http://localhost:86/app/dashboard)に変換され、他のすべての再指示が正しく機能します。HTML 5モードのディープリンクとリフレッシュが動作しないAngularJS

問題は、完全なURL(例:http://localhost:86/app/dashboard)を開いたり、index.htmlページを読み込んだりして、ロゴや画像などの静的コンテンツしか表示せず、動的Webページを表示しないときに発生します。 ng-viewportセクションに示されています。任意のページのリロード時に同じ動作があります。

以下は私が書いたコードです。

JSコード。

$locationProvider.html5Mode({ enabled: true });

HTMLコード

<head> 
    <base href="/"/> 
</head> 
<body> 
    <div> 
     <img class="rotate" src="../assets/img/logo_img.png" /> 
    </div> 
    <div style="height: 100%" ng-viewport autoscroll> 
    </div> 
</body> 

のWeb.Config

<?xml version="1.0" encoding="UTF-8"?> 
<system.webServer> 
    <defaultDocument> 
     <files> 
     <clear /> 
     <add value="index.html" /> 
     <add value="Default.htm" /> 
     <add value="Default.asp" /> 
     <add value="index.htm" /> 
     <add value="iisstart.htm" /> 
     <add value="default.aspx" /> 
     </files> 
    </defaultDocument> 
    <security> 
     <requestFiltering> 
     <hiddenSegments> 
      <remove segment="App_Data" /> 
     </hiddenSegments> 
     </requestFiltering> 
    </security> 
    <rewrite> 
     <rules> 
     <clear /> 
     <rule name="AngularJS" enabled="true"> 
      <match url=".*" /> 
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> 
       <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
       <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
       <add input="{REQUEST_URI}" pattern="^/(Api)" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="/" /> 
     </rule> 
     </rules> 
    </rewrite> 
</system.webServer> 

ルート設定コード

static $routeConfig = [{ 
     path: '/dashboard/:type', 
     component: 'dashboard' 
    }, { 
     path: '/dashboard', 
     component: 'dashboard' 
    }, { 
     path: '/mail', 
     component: 'mail' 
    }, { 
     path: '/solution/:id', 
     component: 'solutionDetails' 
}] 

答えて

0

問題は、jsファイルとcssファイルの相対パスと絶対パスに関連していました。 私はindex.htmlでロードしているすべてのファイルパスの前に/を追加しましたが、今はすべてが魅力的です。

**Earlier :** <script src="app.js"></script> 

**Now:** <script src="/app.js"></script> 
関連する問題