如何将AngularJs代码转换为Angular 6

时间:2019-07-19 17:09:16

标签: angularjs angular typescript

下面是用Angular.js编写的代码。如何在Angular 2+中进行转换。我尝试在component.ts中使用@ angular / router。但是会出现很多错误。

我对angular还是陌生的,因此在开发应用程序时会遇到很多问题。

<script src="https://cdn.jsdelivr.net/npm/boomerangjs@1.650.0/boomerang.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/boomerangjs@1.650.0/plugins/rt.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/boomerangjs@1.650.0/plugins/navtiming.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/boomerangjs@1.650.0/plugins/auto-xhr.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/boomerangjs@1.650.0/plugins/spa.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/boomerangjs@1.650.0/plugins/angular.js"></script>



<script>
 BOOMR.init({ 
  ResourceTiming: {
    enabled: true,
    clearOnBeacon: true,    
  },
  Angular:{
    enabled:true
  },
  autorun: false,   
  instrument_xhr: false  

});


module.run(['$rootScope', function($rootScope) {
var hadRouteChange = false;
$rootScope.$on("$routeChangeStart", function() {
    hadRouteChange = true;
});

function hookAngularBoomerang() {
    if (window.BOOMR && BOOMR.version) {
        if (BOOMR.plugins && BOOMR.plugins.Angular) {
            BOOMR.plugins.Angular.hook($rootScope, hadRouteChange);
        }
        return true;
    }
}

if (!hookAngularBoomerang()) {
    if (document.addEventListener) {
        document.addEventListener("onBoomerangLoaded", hookAngularBoomerang);
    } else if (document.attachEvent) {
        document.attachEvent("onpropertychange", function(e) {
            e = e || window.event;
            if (e && e.propertyName === "onBoomerangLoaded") {
                hookAngularBoomerang();
            }
        });
    }
}
}])




BOOMR.subscribe('before_beacon', function(beaconData) {
  if (beaconData.u.indexOf("/")) {
    // take some action based on the page
    alert(beaconData["rt.start"]);
    alert(beaconData["rt.bmr"]);
  } 

});


</script>

我必须使用它来测量2+角的性能。

1 个答案:

答案 0 :(得分:1)

您必须从头开始工作,作为角度版本2上的一个新项目。无法将角度js转换为角度2