【发布时间】:2021-10-14 22:26:09
【问题描述】:
您好,我在 js 文件中有一个全局变量,我想在 hbs 文件中检索该变量的值
export default () => {
selectedViolationTypeId: 0,
addProgram(program) {
this.set('selectedViolationTypeId', program.ViolationTypeId);
},
}
在 addProgram 函数调用中 selectedViolationTypeId 的值发生了变化,我想在 hbs 文件中检索更改的值,在 URL 字段中,如下所示: url='api/branch/inspectionitemcategories/dt?violationTypeId={selectedViolationTypeId}'
<div class="col-md-8">
{{log 'selectedViolationTypeId'}}
{{log selectedViolationTypeId}}
<div class="form-group chosen-fix {{if failTest 'has-error q'}}">
<label class="control-label">Inspection Item Categories</label>
{{#drop-down url='api/branch/inspectionitemcategories/dt?violationTypeId={selectedViolationTypeId}'
id='idInspectionItemCategories'
required=false
placeholder='Add Program (Search)'
showSelected=false f=f as |item|
}}
{{log 'item 1'}}
{{log item}}
{{#if item}}
{{partial 'components/edit-item/partial-select1'}}
{{else}}
<i>Nothing Here</i>
{{/if}}
{{/drop-down}}
</div>
</div>
但它没有发生,在 url 字段中,这个选定的值是 null 并带有如下错误消息
:56974/api/branch/inspectionitemcategories/dt?violationTypeId={{this.selectedViolationTypeId}}:1 Failed to load resource: the server responded with a status of 400 (Bad Request)
api.js:77 api/branch/inspectionitemcategories/dt?violationTypeId={{this.selectedViolationTypeId}} error undefined Object
有人可以帮我如何在前端 hbs 文件中检索它的值吗?
【问题讨论】:
标签: javascript html ember.js