0

在这里,我正在使用 spring-boot+security 应用程序中的角度路由。当我使用 ui-sref 访问 $stateProvider 中定义的状态时,整个页面都会刷新。如何停止刷新并仅附加 url 并查看模板?

angularJS代码:

myApp.config(function($stateProvider, $urlRouterProvider) {
  // $urlRouterProvider.otherwise('/');
   $stateProvider
    .state('hi', {
        url: '/hi/:id',
        reloadOnSearch : false,
        views :{
            "properties" : {
                templateUrl: "views/properties.html",
                controller : function($scope,$stateParams){
                    //alert("hi");
                }
            }
        }
    });
});

HTML 代码:

<div class="col-md-7" ui-sref="hi ({Id: 1})"> 
       <h5 class="widget-title smaller" >{{id.name}}</h5>
</div>
4

1 回答 1

0

你不应该同时使用 ngRoute 和 UI-router。这是 UI-router 的示例代码:

repoApp.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider
    .state('state1', {
      url: "/state1",
      templateUrl: "partials/state1.html",
      controller: 'YourCtrl'
    })

    .state('state2', {
      url: "/state2",
      templateUrl: "partials/state2.html",
      controller: 'YourOtherCtrl'
    });
    $urlRouterProvider.otherwise("/state1");
});

我希望这可以为您提供解决方案。

于 2016-06-24T12:10:56.577 回答