Я только начал работать с использованием angular2, а компоненты CSS работают нормально. Однако, когда я включаю компонент, который нуждается в инициализации (например, select), я не знаю, как и где это сделать.Как инициализировать компонент для измерения угла?
Это фрагмент из моей формы:
<div class="input-field col s12">
<select>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label>Materialize Select</label>
</div>
Мой компонент выглядит примерно так:
import {Component, ElementRef, Inject, OnInit} from '@angular/core';
import {MaterializeDirective} from "angular2-materialize";
declare var jQuery:any;
@Component({
selector: 'bsi-signup',
styleUrls: ['assets/styles/app.component.css'],
templateUrl: 'assets/templates/signup.component.html',
directives: [MaterializeDirective],
providers: []
})
export class SignupComponent implements OnInit {
elementRef: ElementRef;
constructor(@Inject(ElementRef) elementRef: ElementRef) {
this.elementRef = elementRef;
}
ngOnInit() {
jQuery(this.elementRef.nativeElement).find('select:not([multiple])').material_select();
}
}
@ muetzerich Да спасибо, я действительно заметил себе второе я отправил вопрос (типичный). : P – fowdie