How to trigger an event only when the user changes the URL?

前端 未结 2 949
暖寄归人
暖寄归人 2020-12-04 02:52

I am working on a Chrome extension, I want to detect when the user has typed a URL. I know about:

chrome.tabs.onUpdated.addListener(eventLisenerObj.onUpdated         


        
2条回答
  •  臣服心动
    2020-12-04 03:17

    You can have a look at $locationChangeSuccess.

    You can get the path like this:

    var loc = $location.path();
    

    Then on change of loc you can attach your function.

提交回复
热议问题