2016-10-20 6 views
2

내 각 응용 프로그램이로드로드. 버튼을 secound 시간을 클릭하면 angular2가 처음로드 될 때 zone.js 내용이로드되어 있기 때문에, 그것은 나에게 Zone already loaded 오류를 제공합니다. zone.js : 25 catch되지 않은 오류 : 존은 이미 버튼의 클릭에

어떻게 그때 이미로드 영역을 확인합니다 사용 가능한 경우를로드하려고하는 것을 방지 할 수 있습니까? 내가 delete window['zone']에 의해 (아래 대답) 영역을 삭제하고 다시 그것을 다시로드 할 때의이 같은 시도 할 수 zone.js:984 Uncaught ReferenceError: Zone is not defined

+0

추가하십시오 귀하의 문제를 나타내는 몇 가지 코드 – yurzui

+0

내 프로젝트를 빌드하기 위해 angular-cli를 사용하고 있습니다. 한번 빌드하면 zone.js를 포함하여 2 개의 파일 만 생성되고 단추를 클릭하면 각도 응용 프로그램이로드됩니다. 단추가 두 번째로 클릭되면 오류가 표시됩니다. –

+0

요점은 내가 각도-CLI에 의해 생성 된 파일을 편집 영역이로드되지 않거나 있는지 확인하지만 어떻게 내가 각-CLI 또는 다른 방법을 통해이 자동으로 할 수 있습니다입니다. –

답변

0

을 보여주는

...

$(function(){ 
 
\t \t function removejscssfile(filename, filetype){ 
 
\t \t var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determine element type to create nodelist from 
 
\t \t var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determine corresponding attribute to test for 
 
\t \t var allsuspects=document.getElementsByTagName(targetelement) 
 
\t \t for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove 
 
\t \t if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1) 
 
\t \t  allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild() 
 
\t \t } 
 
\t \t } 
 
\t var jsCustomerTag = $("head").children("#jsShimTag"); 
 
    if (jsCustomerTag.length == 0) { 
 
    \t jsCustomerTag = document.createElement('script'); 
 
    \t jsCustomerTag.setAttribute("type", "text/javascript"); 
 
    \t jsCustomerTag.setAttribute("src", " <your js file> "); 
 
    \t jsCustomerTag.id = "jsShimTag"; 
 
     document.getElementsByTagName("head")[0].appendChild(jsCustomerTag); 
 
    } 
 

 
    jsCustomerTag = null; 
 
});

+0

이것은 브라우저에서 스크립트를 제거하고 다시로드하는 한 방법입니다. 그것을 시도하자. –