Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Angular2+中向select by指令添加选项;_Angular_Angular Directive - Fatal编程技术网

如何在Angular2+中向select by指令添加选项;

如何在Angular2+中向select by指令添加选项;,angular,angular-directive,Angular,Angular Directive,我想为HTMLSELECT元素编写一个指令,该指令应该发送http请求并自动填充其内容 用法示例: <select class="form-control" [loadPeople]="true" required></select> 指令: @Directive({ selector: '[loadPeople]'}) export class LoadPeopleDirective { constructor(

我想为HTMLSELECT元素编写一个指令,该指令应该发送http请求并自动填充其内容

用法示例:

<select class="form-control" [loadPeople]="true" required></select>


指令:

@Directive({ selector: '[loadPeople]'})
export class LoadPeopleDirective {

  constructor(
    private templateRef: TemplateRef<any>,
    private viewContainer: ViewContainerRef) { }

  /* Some code */

}
@指令({选择器:'[loadPeople]})
导出类LoadPeopleDirective{
建造师(
私有templateRef:templateRef,
私有viewContainer:ViewContainerRef{}
/*一些代码*/
}
我如何实现这一点