Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngRoute): instantiate controller when template is empty #5550

Closed
wants to merge 1 commit into from

Conversation

caitp
Copy link
Contributor

@caitp caitp commented Dec 28, 2013

Before this change, $route controllers are not instantiated if the template is falsy, which includes the empty string. This change tests if the template is not undefined, rather than just falsy, in order to ensure that templates are instantiated even when the template is empty, which people may have some reason to do.

This "bug" was reported in http://robb.weblaws.org/2013/06/21/angularjs-vs-emberjs/, as a "gotcha" for AngularJS / ngRoute.

http://plnkr.co/edit/ugXbMOinzRg05CH3LUkO?p=preview a demo of it in practice

Before this change, $route controllers are not instantiated if the template is falsy, which includes
the empty string. This change tests if the template is not undefined, rather than just falsy, in
order to ensure that templates are instantiated even when the template is empty, which people may
have some reason to do.

This "bug" was reported in http://robb.weblaws.org/2013/06/21/angularjs-vs-emberjs/, as a "gotcha"
for AngularJS / ngRoute.
@caitp
Copy link
Contributor Author

caitp commented Dec 28, 2013

Justification: while the docs are pretty clear about it not instantiating controllers without templates, technically an empty string is still a template, so it's an unexpected failure for it not to work.

Besides, people are asking for ways to instantiate controllers without templates for some reason or other rather frequently, so there's that.

@IgorMinar IgorMinar closed this in 498365f Dec 28, 2013
@IgorMinar
Copy link
Contributor

makes sense, thanks

jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
Before this change, $route controllers are not instantiated if the template is falsy, which includes
the empty string. This change tests if the template is not undefined, rather than just falsy, in
order to ensure that templates are instantiated even when the template is empty, which people may
have some reason to do.

This "bug" was reported in http://robb.weblaws.org/2013/06/21/angularjs-vs-emberjs/, as a "gotcha"
for AngularJS / ngRoute.

Closes angular#5550
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
Before this change, $route controllers are not instantiated if the template is falsy, which includes
the empty string. This change tests if the template is not undefined, rather than just falsy, in
order to ensure that templates are instantiated even when the template is empty, which people may
have some reason to do.

This "bug" was reported in http://robb.weblaws.org/2013/06/21/angularjs-vs-emberjs/, as a "gotcha"
for AngularJS / ngRoute.

Closes angular#5550
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants