AngularJS - using ngTouch redirection with ngRoute doesn't work with href and ng-click attribute

前端 未结 1 1706
孤街浪徒
孤街浪徒 2021-01-21 19:08

I navigate through the app with ngRoute. I use links like:

Link

Since I

相关标签:
1条回答
  • 2021-01-21 19:31

    It is an old bug, that wasn't fixed before this time. Href and ng-click doesn`t work together.

    A workaround could be to use an empty href and put the navigation logic into ng-click using $location.

    Proof: https://github.com/angular/angular.js/issues/5307#issuecomment-30024683

    In HTML:

    <a href="" ng-click="showOffCanvas = false; goTo('#/page2')">Link</a>
    

    In controller:

    $scope.goTo = function(refer){
        $location.path(refer)
    };
    
    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题