mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 15:40:22 +00:00
revert ng:view sync caching
sync caching in ng:view must be reverted becase ng:view uses $route.onChange to listen for changes. $route fires all onChange events before it calls $become(Controller) which means that if the template being included via ng:view contains ng:controller, ng:include or other widget that create new scopes, these scopes will be created and initialized before the parent scope is fully initialized (happens after $become is called). For this reason ng:view must be async. The new scope implemenetation will resolve this issue by providing us with an api to register one-off tasks to be executed during the flush phase. We'll be able to compile and link the included template safely at this time.
This commit is contained in:
parent
38ec6519a3
commit
9bd2c3967b
1 changed files with 3 additions and 2 deletions
|
|
@ -1072,10 +1072,11 @@ angularWidget('ng:view', function(element) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src) {
|
if (src) {
|
||||||
$xhr('GET', src, null, function(code, response){
|
//xhr's callback must be async, see commit history for more info
|
||||||
|
$xhr('GET', src, function(code, response){
|
||||||
element.html(response);
|
element.html(response);
|
||||||
compiler.compile(element)(childScope);
|
compiler.compile(element)(childScope);
|
||||||
}, false, true);
|
});
|
||||||
} else {
|
} else {
|
||||||
element.html('');
|
element.html('');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue