I want to include Polymer Elements into my angular2 App since Angular2 Material still doesn't provide enough elements. Additionally, I want to style the element, i.e. setting the width of it. I have
<paper-dropdown-menu class="dropdown" label="Wiederholung" vertical-align="bottom" horizontal-align="right">
<paper-listbox class="dropdown-content">
<paper-item>einmalig</paper-item>
<paper-item>wöchentlich</paper-item>
<paper-item>monatlich</paper-item>
</paper-listbox>
</paper-dropdown-menu>
EDIT
in my index.html I have
<!-- polymer components -->
<script src="/node_modules/bower_components/webcomponentsjs/webcomponents.js"></script>
<script>
window.Polymer = window.Polymer || {};
window.Polymer.dom = 'shadow';
</script>
<link rel="import" href="/node_modules/bower_components/polymer/polymer.html">
<!-- custom style for polymer components -->
<style is="custom-style">
:root {
--paper-dropdown-menu : {
width: 280px;
}
}
</style>
<link rel="import" href="/node_modules/bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="/node_modules/bower_components/paper-listbox/paper-listbox.html">
<link rel="import" href="/node_modules/bower_components/paper-item/paper-item.html">
<link rel="import" href="/node_modules/bower_components/paper-input/paper-input.html">
Interestingly, I can change the with to i.e. 100px and it will be applied. But it won't get higher than ~250px;
Having this in my index.html solved my problem:
You can use such a style element in
index.html
or you can wrap your Polymer elements in a custom Polymer element including the style for the wrapped HTML
and then use it like this in you Angular component
A few posts that explain some topics about how to use Polymer with Angular2
these tutorials are for Polymer.dart with Angular2 for Dart but it shouldn't be too hard to apply the information to Polymer.js with Angular2 with TS.