如何调用变更网址后angularjs功能 [英] how to call a function in angularjs after change url

查看:160
本文介绍了如何调用变更网址后angularjs功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用NG-的init =isauthorised()在我的code得到调用函数改变每个URL后

I have used ng-init="isauthorised()" in my code to get call function after changing every URL

它打电话的时候,页面刷新获得,但我需要这个功能得到调用AFER每点击ancher标签

it call when page get refresh but I need this function to get call afer every click on ancher tag

推荐答案

一做的最好的事情就是使用路由提供商调用函数页改变发生之前。这(从这里修改)的一个例子是:

One of the best things to do is to use the route provider to call a function before the page change happens. One example of this (modified from here) is:

$scope.$on('$locationChangeStart', function(event) {
    // call your method here
});

这个的好处是,你知道你的程序将会被调用,你不必修改code为每个页面上的锚标记。顺便说一句,如果你有兴趣了解更多信息,这里查看角文档

The nice thing about this is you know your routine is going to get called and you don't have to modify the code for every anchor tag on the page. By the way, if you are interested in more information check the angular documentation here.

这篇关于如何调用变更网址后angularjs功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆