[英]How to communicate between mvc partial view and angular component
How can i call a method inside the angular component when i change the drop down in the partial view. 当我更改局部视图中的下拉菜单时,如何在角度组件内部调用方法。
I have a Partial view with a drop down control and an angular component in my mvc page. 我的mvc页面中有一个带有下拉控件和角度组件的Partial视图。 When i change my drop down in the partial view(created using razor engine), i need to trigger a method inside the angular component.
当我在局部视图中更改下拉菜单(使用剃刀引擎创建)时,我需要在角度组件内部触发一个方法。
I found a workaround. 我找到了解决方法。 Add a input on the angular component html
在角度组件html上添加输入
<input type="hidden" id="selDate"/>
attach an onChange event in the corresponding .ts file 在相应的.ts文件中附加一个onChange事件
$(function () {
$('#selDate').on('change', function () {
var dt = $('#selDate').val();
self.getIRData(dt);
});
});
set the value of the above control from the partial view(dropdown change event) and simulate an onChange event by adding Dispatchevent() 从局部视图(下拉更改事件)设置上述控件的值,并通过添加Dispatchevent()模拟onChange事件
please let me know if you have any better workarounds 如果您有更好的解决方法,请告诉我
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.