-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding attributes to the component tag that is being generated by ui-router #3385
Comments
We already allow arbitrary templates to be used, i.e.:
But you then obviously lose the route-to-component data bindings feature. I think we could allow a callback which post-process the route-to-component template that ui-router builds. We'd just need to decide on the best API, or how to leverage the existing APIs ( |
"But you then obviously lose the route-to-component data bindings feature." Could it be as simple as a property 'componentAttributes' in the state definition that takes an object whos key value pairs get generated as attributes with respective values? |
Hi - isn't this possible with the newly available bindings on the uiView (#3239)? We are using this mechanism to pass parameters to the assigned components to the uiView (as well as the '&' bindings to inform it's parent. here's what the generated HTML looks like:
The param is only coming from uiView and the res1 & res2 are resolves. |
This is also kinda of breaking my migration from template/controller to components. I am being "forced" to do
instead of a simple
Because i need those attributes present on the parent container of my component html for it to render proper. |
@elincognito I'm facing the same issue here. I believe your suggestion to use I guess it would be interesting if the generated tag could inherit the attributes from the parent:
|
I ran into the same issue, where angular material requiring flex and layout attributes on every element child to make sticky toolbars work. My workaround for now.. My ui-view is defined with On every completed state transation I manually add the classes normally added by the material attributes to the unreachable
combined with defining state components in the state config Using: angular-material 1.1.5, ui-router 1.0.6 |
Using this ugly-but-not-so-ugly workaround to add attributes required by my Angular Material layout. First I add the resolves to the state definition:
Then the bindings to my component:
Resulting template:
|
@peterpoe Very clever solution! |
@peterpoe thanks thats a pretty smart way of going about it. Still a documented api way that directly solves this problem would be nice. Any update on that, ui router devs? |
@peterpoe 's solution is a great workaround and it totally solves the problem! But, it's still a WORKAROUND... can you please provide an api way to do that? And it could be useful too having a way to apply that to all views, like a property for the $stateProvider instead of defining it for all states. |
Same problem with ui-router and angular material layout also for me. |
Using the @christopherthielen any chance of moving forward with the callback which post-process the route-to-component template that ui-router builds? |
My alternative workaround: Knowing that there is only 1 child element to ui-view (the starting component), and that whatever the component is, I want to add these styles for layout, I created a custom CSS rule for it:
This could be extended to apply only to certain components by specifying the component name in the rule |
This issue has been automatically marked as stale because it has not had This does not mean that the issue is invalid. Valid issues Thank you for your contributions. |
Hello devs,
First of all, thanks for the awesome work on this repository! Keep it up!
I have the following problem:
When UI router routes to a component it automatically creates the component tag. eg
<my-comp></my-comp>
and nests it under the ui-view element. This all works great untill you combine it with a framework like Bootstrap or Angular Material that use classes to affect direct children of an element for layout.For example the generated html output would be:
With this output #childelement does not get the layout styling it needs because the tag is in between the layout element and the child element. I understand that this behavior is in fact correct. UI-view nests a component, a component nests its template, hence the result.
I could of course add styling to the component as a work around but what I really want is to be able to add attributes to the component tag that is being generated. That way I can easily use my layout framework in combination with ui router and components. Is this something that is possible and/or is it something that you are willing to add?
The text was updated successfully, but these errors were encountered: