AngularJS :是否可以在一个应用程序中加载两个不同的 html 和两个不同的路由器(每个路由器一个。html)?

AngularJS : Is it Possible to load two different html with two different routers(one for each .html) in one single application?

我有两个 HTML 文件 -> index.htmlstart.html

到目前为止,我正在开发一个单一维度的应用程序(一个小应用程序),其中 index.html 用作主页,app-route 用作应用程序的主路由器。现在我们正在创建一个更大的应用程序,如 .com 站点,并将以前的应用程序与 this(.com).

集成

我们不想打扰较小的应用程序代码,我们正在开发一个 .com 站点,它是一个不同的 html(start.html) 和一个不同的路由器 (dot-com-route.js ).现在,每当我尝试加载 http://localhost/myApp/app/#/start.html 时,它都会使用 app-route.js?

加载 index.html

是否总是这样,angular 应用程序寻找 index.html 文件来执行?

这是我的应用-route.js:

smartPrintApp.config(['$routeProvider','$locationProvider',
  function($routeProvider, $locationProvider) {
      $routeProvider.
      when('/', {
        templateUrl: 'pages/smart_print_landing/smart-print-landing.html'
      }).
      when('/index.html', {
        templateUrl: 'pages/smart_print_landing/smart-print-landing.html'
      })
  }
]);

当您尝试打开 http://localhost/myApp/app/#/start.html the part of the URL that the server will actually try to serve is http://localhost/myApp/app/ 时。服务器向浏览器发送请求的页面后 AngularJS 将发挥作用并读取 has (#) 之后的部分以确定使用哪个路由。由于您没有在服务器正在读取的部分中包含特定的 HTML 文件,服务器将提供已设置为默认值的 HTML 文件(我从您得到的行为假设是 index.html)。

因此,为了获得您的第二个着陆页,您应该使用 http://localhost/myApp/app/start.html/#/(或类似的内容,具体取决于您希望访问的路线)作为 URL。