【问题标题】:angularjs and asp.net routing mixangularjs 和 asp.net 路由组合
【发布时间】:2014-10-14 10:33:14
【问题描述】:

我在我的 asp.net mvc 应用程序中使用 angularsj 路由。

这是我对 $routeProvider 的配置:

.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {

    $locationProvider.html5Mode(true);
    $routeProvider
      .when('/Organization/Employee/:id', {
          controller: 'UserCtrl',
          templateUrl: '/Areas/Organization/App/user/partial/info.html'
      })
      .when('/Organization/Employee/:id/edit', {
          controller: 'EditCtrl',
          templateUrl: '/Areas/Organization/App/user/partial/edit.html'
      })
    .otherwise({        
        redirectTo: '/'
    })
    ;
}])

如您所见,我只希望 angularjs 处理两条路线。 我如何使用 asp.net 来处理其他情况下的路由?

【问题讨论】:

    标签: asp.net-mvc angularjs routing


    【解决方案1】:
      .otherwise({
          controller: function ($location, $window) {
              $window.location.href = $location.path();
              return false;
          },
          template: ""
      });
    

    成功了。但是先用一个空的 ng-view 闪烁。也许有人知道如何摆脱这种眨眼?

    【讨论】:

      猜你喜欢
      • 2018-06-04
      • 2014-11-22
      • 1970-01-01
      • 1970-01-01
      • 2015-07-08
      • 2014-12-09
      • 2016-04-26
      • 2015-07-06
      • 1970-01-01
      相关资源
      最近更新 更多