即使在服务器

时间:2015-08-11 08:26:21

标签: javascript angularjs iis

我的应用程序中有4个文件(在同一目录中),它部署在IIS上 -

  1. home.html的
  2. Angular.js
  3. data.txt中
  4. web.config(IIS为默认文档生成的自动)
  5. 我想要显示' data.txt'的内容。 on' home.html'。 相同的代码在[Plunker] [1]

    运行

    这个主页'文件有以下代码。

    <!DOCTYPE html>
      <html>
     <head>
    <title>nitin</title>
    <script src="angular.js" type="text/javascript"></script>
    <script type="text/javascript">
        var nameSpace = angular.module("app", []);
        nameSpace.controller("GuitarFunction", function ($scope) {});
      </script>
     </head>
     <body ng-app="app">
     <div ng-controller="GuitarFunction">     
        <ng-include src="'data.txt'">
        </ng-include>
     </div>
    </body>
    </html>
    

    http://plnkr.co/edit/8aBJsqzV07AweDk4PAcG?p=preview

2 个答案:

答案 0 :(得分:0)

网站需要托管在网络服务器(IIS,Apache)中,因此可以通过http / https提供。

如果协议是file://。

,浏览器安全措施将阻止脚本加载外部资源

例如,如果您在端口5000上的IIS中托管了C:\ webapp,则需要将浏览器定向到http://localhost:5000/index.html而不是C:\ webapp \ index.html。

答案 1 :(得分:0)

如果您的网站没有服务器代码,则需要在web.config中包含覆盖,然后您只覆盖应用程序的名称,如

<?xml version="1.0" encoding="utf-8"?>
 <configuration>
<system.webServer>
  <handlers>
       <add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
  </handlers>
  <rewrite>
       <rules>
            <rule name="DynamicContent">
                 <conditions>
                      <add input="{{REQUEST_FILENAME}}" matchType="IsFile" negate="True"/>
                 </conditions>
                 <action type="Rewrite" url="server.js"/>
            </rule>
       </rules>
  </rewrite>     

  

相关问题