Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.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
Javascript 防止在以角度加载组件时更改无线电值时出错_Javascript_Angular_Typescript_Radio Button - Fatal编程技术网

Javascript 防止在以角度加载组件时更改无线电值时出错

Javascript 防止在以角度加载组件时更改无线电值时出错,javascript,angular,typescript,radio-button,Javascript,Angular,Typescript,Radio Button,请帮助我尝试使用单选按钮设置日期,但在加载组件时更改值时出错 html.component.html 。。。 1周 1个月 三个月 6个月 ... html.component.ts 。。。 AsperioDBTN='1W'; ... ngAfterViewInit(){ 本设定日期('1M'); } 设定日期(期间){ this.asPeroidBtn=周期; } ... 通过使用此选项,我得到了一个错误: ERROR Error: ExpressionChangedAfterItHasB

请帮助我尝试使用单选按钮设置日期,但在加载组件时更改值时出错

html.component.html

。。。
1周
1个月
三个月
6个月
...
html.component.ts

。。。
AsperioDBTN='1W';
...
ngAfterViewInit(){
本设定日期('1M');
}
设定日期(期间){
this.asPeroidBtn=周期;
}
...
通过使用此选项,我得到了一个错误:

ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value for 'checked': 'true'. Current value: 'false'.
    at throwErrorIfNoChangesMode (core.js:5625)
    at bindingUpdated (core.js:13962)
    at Module.ɵɵproperty (core.js:14706)
    at GNB5100Component_Template (html.component.html:36)
    at executeTemplate (core.js:7449)
    at refreshView (core.js:7318)
    at refreshComponent (core.js:8465)
    at refreshChildComponents (core.js:7126)
    at refreshView (core.js:7368)
    at refreshEmbeddedViews (core.js:8419)

请帮助修复此错误。

ngAfterViewInit更改为ngAfterContentInit,错误将不会发生

有关更多信息,请在此处查看此答案


为什么不能将AsperioDBTN值默认设置为“1M”?@PiyushJain我有其他理由将此默认设置为“1W”,但在某些情况下,我需要将其设置为“1M”,但如果我将其设置为“1M”,则会出现错误。谢谢您的回答,非常好