Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.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
Angular 角度4-显示和隐藏组件_Angular_Angular Template - Fatal编程技术网

Angular 角度4-显示和隐藏组件

Angular 角度4-显示和隐藏组件,angular,angular-template,Angular,Angular Template,我在同一个html文件中有下一个组件 只需将变量设置为true和false即可 联系人 结果 您可以使用隐藏属性或*ngIf指令: 只是使用它 打字稿: public show:boolean=false; 公共按钮名称:any=true; 切换(){ this.show=!this.show; if(this.show) this.buttonName=false; 其他的 this.buttonName=true; } HTML: 是的,我以前试过,但没有发生任何事情,可能我必须在组

我在同一个html文件中有下一个组件



只需将变量设置为true和false即可

联系人
结果

您可以使用隐藏属性或
*ngIf
指令:


只是使用它

打字稿:

public show:boolean=false;
公共按钮名称:any=true;
切换(){
this.show=!this.show;
if(this.show)
this.buttonName=false;
其他的
this.buttonName=true;
}
HTML:



是的,我以前试过,但没有发生任何事情,可能我必须在组件上传递“isOn”作为参数,从子到父,从父到子,这四个组件在组件“app main”中,这将是组件父亲。这会在条件得到满足后触发ngcycle事件吗?如果这样做,我们必须将自己的导航周期连接到整个应用程序,默认返回将不起作用。让整个应用程序遵循这种显示和隐藏组件的结构可以吗?