【问题标题】:ng-view not working on Microsoft Edgeng-view 在 Microsoft Edge 上不起作用
【发布时间】:2015-11-30 07:25:56
【问题描述】:

我正在 Microsoft Edge 上测试我的应用程序并引发此错误:

    app.config(
        function ($routeProvider) {
      $routeProvider.
          when('/logout', {
              template: '<logout-page></logout-page>'
          })
          .when('/', {
              template: '<application-manage></application-manage>'
          })
});

在我的索引中:

<body  style="height: 100%">
<div class='main-div' style="height: 100%;" ng-view ng-class="slide">Loading....</div>
</body>

对于第一种情况:'&lt;application-manage&gt;&lt;/application-manage&gt;' 它工作正常。但是当我点击注销时。它抛出错误:

SyntaxError <div class="main-div ng-scope" style="height: 100%" ng-class="slide" ng-view="">

谢谢大家。问题解决了,是因为我使用的是基本认证的方式:

jQuery.ajax({
              type: "GET",
              url: logoutURL ,
              async: true,
              username: fakeUser,
              password: fakePassword,
              headers: {"Authorization": "Basic Authorization"}
          }).done(function () {
             console.log("Can not logout Basic Authentication in this browser");
         defer.resolve(true);
            }).fail(function () {
                console.log("You have successfully logged out!");
                defer.resolve(true);
           });

发件人:http://stackoverflow.com/questions/233507/how-to-log-out-user-from-web-site-using-basic-authentication

【问题讨论】:

  • logoutPage 指令是什么样的?
  • 我了解到您使用的是常规的 $routeProvider。如果可能,我强烈建议使用 ui-router 尝试此功能:github.com/angular-ui/ui-router。去年 ng-conf 的 Angular 团队暗示每个人都应该使用 ui-router(这是他们将为 Angular 2 建模的东西)。这可能会停止您使用 ng-view 的需要,正如 Fabrice 建议的那样,这可能会导致您的 SyntaxError。
  • @Claies 所说的,发布您的注销页面和应用程序管理指令模板
  • @Dakky,请发布您的指令。此外,小提琴/掠夺会有所帮助。

标签: angularjs angularjs-directive angularjs-ng-click microsoft-edge ng-view


【解决方案1】:
Try:

   app.config(
        function ($routeProvider) {
      $stateProvider
                .state('/logout', {
url:'/logout',
              template: '<ui-view>'
          })
          .state('/', {
url:'/',
              template: '<ui-view>'
          })
});

You can Also use external html file, in this case use **templateUrl:'your file.html'**

【讨论】:

  • 我觉得好像不太可能解决指定的问题,因为它包含错误,例如 $routeProvider$stateProvider 不同,并且 $stateProvider 是 @987654325 提供的附加组件操作未指定用于此特定实现的@。
【解决方案2】:

建议在这里,您能否在 HTML 中为应用提供如下名称:

ng-app="XYZManagementApp"

【讨论】:

  • 我非常怀疑这是否可行,甚至不清楚这是从哪里来的,因为他们从未在样本中列出 ng-app。
猜你喜欢
  • 1970-01-01
  • 2020-03-07
  • 2016-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-30
  • 1970-01-01
  • 2019-02-14
相关资源
最近更新 更多