You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
I have faced a problem concerning browser sync and usage of not cached html templates (by cached I refer to the ones converted to .js file with appropriate initialization of $templateCache). When running gulp serve all html files that are asynchronously loaded by angular js are extended by browser sync with a custom script tag. Unfortunately it can lead to some problems. In my case the problem was revealed when adding ui-router to the project. In final step of view switching it runs:
In current project configuration jQuery is plugged in and as a result its implementation of .html is being called. jQuery is so smart that it copies all scripts and then run global eval on them:
if(hasScripts){doc=scripts[scripts.length-1].ownerDocument;// Reenable scriptsjQuery.map(scripts,restoreScript);// Evaluate executable scripts on first document insertionfor(i=0;i<hasScripts;i++){node=scripts[i];if(rscriptType.test(node.type||"")&&!data_priv.access(node,"globalEval")&&jQuery.contains(doc,node)){if(node.src){
...
}else{jQuery.globalEval(node.textContent.replace(rcleanScript,""));}}}}
For us it means that script attached by browser sync will run, what causes the whole view to be cleared (I did not check if the same occurs in case of using jqLite).
If we want to provide a flexible and stable development environment it should not cause such exceptions/problems.
Imho html files should not be watched anyway, because if developer has already entered the view, then the template was loaded and cached in $templateCache. Browser sync is able to inform the browser to refresh resources, but not to inform angular to refresh its cache. In case of generated cached templates everything seems to be fine - run method will be executed on the reloaded module so entries in $templateCache will be replaced.
Cheers,
Bartek
The text was updated successfully, but these errors were encountered:
Hi,
I have faced a problem concerning browser sync and usage of not cached html templates (by cached I refer to the ones converted to .js file with appropriate initialization of $templateCache). When running gulp serve all html files that are asynchronously loaded by angular js are extended by browser sync with a custom script tag. Unfortunately it can lead to some problems. In my case the problem was revealed when adding ui-router to the project. In final step of view switching it runs:
In current project configuration jQuery is plugged in and as a result its implementation of .html is being called. jQuery is so smart that it copies all scripts and then run global eval on them:
For us it means that script attached by browser sync will run, what causes the whole view to be cleared (I did not check if the same occurs in case of using jqLite).
If we want to provide a flexible and stable development environment it should not cause such exceptions/problems.
Imho html files should not be watched anyway, because if developer has already entered the view, then the template was loaded and cached in $templateCache. Browser sync is able to inform the browser to refresh resources, but not to inform angular to refresh its cache. In case of generated cached templates everything seems to be fine - run method will be executed on the reloaded module so entries in $templateCache will be replaced.
Cheers,
Bartek
The text was updated successfully, but these errors were encountered: