微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何基于第一个选项使用 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 举报,一经查实,本站将立刻删除。