如何基于第一个选项使用 express 把手、materialise、jQuery 和 ajax 动态填充第二个选择列表?

问题描述

我知道有很多关于这个主题主题,但我似乎找不到与我的案例相似的主题。很多都与静态数据有关。

所以我想要做的是,让用户在第一个选择列表中选择一个选项,然后根据该值,它将填充与该选择相关的任何内容

我正在尝试为练习数组中的每个元素附加一个带有值和文本的“选项”标签,但我的第二个下拉列表根本没有显示选项。

我正在为我的路线和这条特定路线使用 express,我想使用 ajax 来填充第二个下拉列表。我已经尝试了几个小时的很多事情,但我似乎无法解决。我是 node 和 jQuery 的新手。

这是我的 index.hbs 文件

export class SplashScreenComponent implements OnInit {

loaderType: string;
@ViewChild('splashScreen',{static: true}) splashScreen: ElementRef;

constructor(
private el: ElementRef,private layoutConfigService: LayoutConfigService,private splashScreenService: SplashScreenService) {
console.log(el)
}

 ngOnInit() {
 const loaderConfig = this.layoutConfigService.getConfig('loader');
 this.loaderType = objectPath.get(loaderConfig,'page-loader.type');

 this.splashScreenService.init(this.splashScreen);
 }
}

我的脚本中的代码

<div class="row">
            <div class="input-field">
                <select id="program" name="program">
                    <option value="" disabled selected>select..</option>
                    {{#each programs}}
                    <option value="{{_id}}">{{this.name}}</option>
                    {{/each}}
                </select>
                <label>Programs</label>
            </div>
        </div>
        <div class="row">
            <div class="input-field">
                <select id="dayOfWeek" name="dayOfWeek">
                    <option value="" disabled selected>select..</option>

                </select>
                <label>Day Of Week</label>
            </div>
        </div>

非常感谢任何帮助。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)