angularjs - refresh when clicked on link with actual url

后端 未结 10 1245
深忆病人
深忆病人 2020-12-02 10:13

I use routeProvider to define controlers and templates for my urls.

When I click on the link, which has the same url as is the actual location, nothing happens. I w

10条回答
  •  有刺的猬
    2020-12-02 10:22

    From @Renan Tomal Fernandes answer. following is an example

    HTML

    
    

    JS

    angular.module("myModule",[]).
    directive('myRefresh',function($location,$route){
        return function(scope, element, attrs) {
            element.bind('click',function(){
                if(element[0] && element[0].href && element[0].href === $location.absUrl()){
                    $route.reload();
                }
            });
        }   
    });
    

提交回复
热议问题