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

md-tabs: Required causes error when used in default ui-view content #2414

Closed
epelc opened this issue Apr 19, 2015 · 5 comments
Closed

md-tabs: Required causes error when used in default ui-view content #2414

epelc opened this issue Apr 19, 2015 · 5 comments
Assignees
Milestone

Comments

@epelc
Copy link
Contributor

epelc commented Apr 19, 2015

I'm getting the following error when using md-tab within ui-view as the default content after I navigate to a child state.

https://docs.angularjs.org/error/$compile/ctreq?p0=mdTabs&p1=mdLabelTemplate

I have a state with the following template which defines my tabs within a ui-view as the default content.

<div ui-view>
<!-- md-tabs/md-tab would be declared here along with other content -->
</div>

Then a child state's template would replace the md-tabs and all the other default content. If you have any questions please let me know as I haven't seen this method being shown public much(however it is used in the ui-router example app).

I presume this was caused by the recent changes to tabs in 0.9.0-rc1 however I've also encountered the same error on the latest master. I think a simple fix would be to use ?^ and possibly just return if the controller is undefined in md-label-template. There is more info about the syntax on the error page above.

@epelc
Copy link
Contributor Author

epelc commented Apr 19, 2015

I've opened the following issue with ui-router as I think it may be in there power to resolve this for everything. But a temporary fix would be very appreciated.

angular-ui/ui-router#1896

@epelc
Copy link
Contributor Author

epelc commented Apr 20, 2015

@robertmesserle Here is a demo http://plnkr.co/edit/KNQLnO3biwED4FtuwZcP?p=preview click each of the buttons until you get to the some action state also check your console for the error.

@nateabele I couldn't reproduce it with angular-material but I ran into this a few months ago using a component from ui-bootstrap. I think the root issue is a problem with how ui-router removes content from views.

@robertmesserle
Copy link
Contributor

@epelc I think you're right. I wasn't able to find any obvious cause on our end, but I added a fix to at least avoid the error messages that you are receiving. I tested it against your Plunker and it looks to work fine.

@epelc
Copy link
Contributor Author

epelc commented Apr 20, 2015

@robertmesserle Thanks for the fix. I also had this issue for ui-bootstrap before but it was easier to just refactor my states a bit as I wasn't aware of the ^? syntax.

@daniel-nagy
Copy link
Contributor

@AnatolyZ plunker clearly demonstrates this issue. I put a log statement every time we get passed this if statement in the $ViewDirective.

if (!firstTime && previousLocals === latestLocals || scope._willBeDestroyed) return;

As you can see we often step through this logic twice (creating a new scope, possibly transcluding content twice) on $stateChangeSuccess, which I would imagine is not the intended behavior?

The source of the issue may lie somewhere else but this seems off to me.

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

No branches or pull requests

4 participants