Angular2でSelectize.jsを実装しようとしていますが、動作させることができません。ここで私はHTMLコンポーネントで試してみたものです:コンポーネントでAngular2でSelectize.jsを使用するにはどうすればよいですか?
<div class="form-group">
<label for="friends">Friends</label>
<input type="text" class="form-control" #friends
[(ngModel)]="user.friends" name="friends"
#picture="ngModel">
</div>
そして:
declare let $: any;
@Component({
selector: 'app-profile',
templateUrl: './profile.component.html',
providers: [ AuthenticationService, UserService, MessageService ]
})
export class ProfileComponent implements OnInit, AfterViewInit {
@ViewChild('friends') el:ElementRef;
constructor(
private _userService: UserService,
private _authService: AuthenticationService,
) { }
ngAfterViewInit() {
$('#friends').selectize({
delimiter: ',',
persist: false,
create: function(input) {
return {
value: input,
text: input
}
}
});
}
ngOnInit() {
//...
}
onSubmit(event) {
//...
}
}
だから私は単に友人入力でSelectizeを実装されて何をしようとしています。私は、ユーザーが友人の名前を書いて、Angularでそれらの名前を並べ替えることができるようにしたい。
しかし、インターフェースで何も起こらないので、「選択」は何もしません。どうして?