2017-09-27 3 views
0

나는이 nativescript-appList Plugin을 참조했습니다. 이 런타임 오류가 발생했습니다. 정의되지 않은 getPackageManager 속성을 읽을 수 없습니다.angular2 nativescript에서 정의되지 않은 getPackageManager 속성을 읽을 수 없습니다.

나는 angular2-nativescript 내가이 로그을 console.log ("두번째", "테스트")를 참조 드릴 수 없습니다 명령 프롬프트에서

import * as AppList from "nativescript-applist"; 

// inside the constructor 

console.log("First", "Test"); 

    AppList.getInstalledApps(function(apps) { 

     console.log("Second", "Test"); 

     }, { 
      withIcons: true 
     }); 

에 생성자 내부 코드 아래에이 작업을 실행하는거야; .이 로그 만 볼 수 있습니다 console.log ("First", "Test");

답변

2

플러그인은 Angular 프로젝트와 호환되지 않는 것으로 보이지만 쉽게 작동하도록 수정되었습니다. 이를 위해서는 플러그인의 소스 코드를 직접 수정해야합니다. repo를 복제하고 아래의 변경 사항을 적용한 다음 npm pack을 새로 수정하여 tgz 파일을 생성하거나 플러그인을 설치하고 코드를 node_modules/nativescript-applist/Apps.android.js으로 직접 수정하십시오 (node_modules 폴더를 삭제할 때 모든 변경 사항이 제거되므로 좋은 방법은 아닙니다) 열린 node_modules/nativescript-applist/Apps.android.js - - 메소드 내에서 처음 두 유유히로드 특성을 이동

예를 들어

는 각도에서 플러그인 작품은 follwing을 을 만들려면

function getInstalledListOfApps(callback, cfg) { 
    var androidApp = app.android; 
    var androidAppCtx = androidApp.context; 

    // more code follows here 

var androidApp = app.android; 
var androidAppCtx = androidApp.context; 

function getInstalledListOfApps(callback, cfg) { 
    // more code follows here 

전에 그리고 당신은 갈 수 있습니다!

+0

답변 해 주셔서 감사합니다. 작동하지 않아. 나는 그것을 시험했다. – Steve

+1

테스트 프로젝트를 만들었고 위의 변경 사항으로 내 측면에서 예상대로 작동합니다. 플러그인의 소스 파일을 변경하고 있습니까? 변경 사항을 적용하려면'node_modules folder'를 유지하고'platforms' 폴더를 지우고 프로젝트를 다시 빌드해야합니다. –

+0

고마워 그것은 당신이 말한대로 효과가있었습니다. 플랫폼을 제거하고 다시 추가했습니다. – Steve

관련 문제