This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ngInit): evaluate ngInit before ngInclude
The priority of ngInit is adjusted to occur before ngInclude, and after ngController. This enables ngInit to initiallize values in a controller's scope, and also to initiallize values before ngInclude executes. Closes #5167 Closes #5208
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0e50810
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not completely sure this has fixed everything.
I've had to move the ng-init parameter outside of the ng-controller, otherwise the value would stay on undefined. (angular 1.2.5)
Works:
Fails:
0e50810
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SchizoDuckie could you reproduce that in a plnkr? It's not totally clear to me what/why that is failing (not had coffee yet)... looks unrelated to the ng-include + ng-init feature, and more just regarding ng-init + ng-controller (which should still work)
0e50810
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't totally tell what you're doing, but I assume it's something like this: http://plnkr.co/edit/ko8H8BmQjf5TVmDOAjWt?p=preview
If you're expecting the init value to be available immediately when the controller is invoked, unfortunately it isn't (changing that would require hacking compile.js so that init could run as soon as the scope is created, before the controller is invoked --- If we want to add that, that's really a separate bug).
Anyways, I hope that clears things up a bit
0e50810
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @caitp I guess that's exactly what we're doing here.