BOOMR.plugins.Angular
插件似乎用于AngularJS 1.x
,到目前为止,我没有找到可以使用的Angular
示例或插件。基于这些文档,我提出了以下解决方案:
@Injectable()
export class BoomerangBootstrapService implements OnAppInit {
constructor(private router: Router) {}
onAppInit() {
const boomr = window['BOOMR'];
const callbacks = {};
this.router.events.subscribe((e) => {
if (!boomr) {
return;
}
if (e instanceof NavigationStart) {
boomr.plugins.SPA.last_location(e.url);
const callback = () => {
boomr.plugins.SPA.markNavigationComplete();
};
callbacks[e.url] = callback;
boomr.plugins.SPA.route_change(callback, []);
} else if (e instanceof NavigationEnd || e instanceof NavigationCancel || e instanceof NavigationError) {
const callback = callbacks[e.url];
if (callback) {
callback();
delete callbacks[e.url];
}
}
});
}
}
当我使用浏览器控制台插入一个助手diagnostics script
来调试调用时,我可以看到注册是正确的,但我没有看到导航上提交任何数据。
诊断脚本:
(function(spa) {
'use strict';
var rc = spa.route_change;
var ll = spa.last_location;
var cm = spa.markNavigationComplete;
spa.last_location = function(url) {
console.log('last route url was ' + url);
ll(url);
};
spa.route_change = function(c, o) {
console.log('route_change start');
rc(c, o);
};
spa.markNavigationComplete = function() {
console.log('route_change completed');
cm();
};
})(window.BOOMR.plugins.SPA);
我做错什么了吗?我需要创建一个自定义插件还是调用其他方法?你能给我指一个工作代码示例或插件git项目吗?
现在不需要在Angular应用程序中插入任何东西。从Boomerang版本1.632开始,只需检查即可支持所有SPAs
启用单页应用程序(SPA(监控
此处提供文档
https://developer.akamai.com/tools/boomerang/?language=en_US?language=en_US#single-页面应用