Html 布尔值不为';不变

Html 布尔值不为';不变,html,angular,typescript,boolean,primeng,Html,Angular,Typescript,Boolean,Primeng,我有个问题。搜索了几个小时后,我找不到对此的解释。我想显示一个模式(from),并在用户单击按钮时显示它。这个按钮调用(带有id)我的API REST并提供信息,非常简单。我收到了信息,但当模态显示时,这不会发生 map.component.ts 导出类MapComponent实现OnInit{ 公共交互:任何[]; 公共交互:any={}; 显示:布尔=假; /*...*/ 生成数据(地图:L.map){ 常量数据:任意[]=[]; 让标记器:任何; L.geoJson(this.altera

我有个问题。搜索了几个小时后,我找不到对此的解释。我想显示一个模式(from),并在用户单击按钮时显示它。这个按钮调用(带有id)我的API REST并提供信息,非常简单。我收到了信息,但当模态显示时,这不会发生

map.component.ts

导出类MapComponent实现OnInit{
公共交互:任何[];
公共交互:any={};
显示:布尔=假;
/*...*/
生成数据(地图:L.map){
常量数据:任意[]=[];
让标记器:任何;
L.geoJson(this.alteraciones{
pointToLayer:(特性,板条)=>{
标记器=L.标记器(板条{
图标:this.getIconMarker(feature.properties.tipo\u alteracion)
});
marker.on('click',(e)=>{
this.getInfoAlteracion(feature.properties.id_alteracion);//{
this.alteracion=结果;
console.log(this.alteracion);//<==信息正常

this.display=true;//尝试将该布尔显示属性公开!

最后,我解决了这个问题。由于这个原因,我意识到这是库之间的兼容性问题。传单事件处理程序在Angular的区域外运行,在该区域内不会自动检测到对输入绑定字段的更改。为了确保我的更改是e检测并应用,我需要在Angular的区域内进行更改。将此添加到代码中,最后,所有工作:

constructor(private mapService: MapService, private zone: NgZone) { }

 marker.on('click', (e) => {
          this.zone.run(() => {
            this.getInfoAlteracion(feature.properties.id_alteracion);
          });
        });
        data.push(marker);
      }

感谢所有人的帮助!

我在发布此问题之前尝试过,但无效:(实现似乎很好,正如您所说,在服务器停止之前,值正在更改,我认为您的项目设置或API获取端(如订阅服务器)可能存在问题。您需要从这两个方面进行进一步调试。请尝试:
[visible]=“display”
(单向绑定)。不,它也不起作用:/如果在设置
this.display=true;
后将
console.log(“display”,this.display)
放在模板的某个地方(不在模式中),值是否正确?请尝试:
[attr.visible]=”当我重新分配变量时,显示“
两个
控制台.log
{{display}}
显示'false'。仅当我重新编译或关闭服务器时,在一切停止之前,值更改为'true'
<p-dialog header="Info" [(visible)]="display" modal="modal" width="500" [responsive]="true">
<!--some code-->
  <p-footer>
    <button type="button" pButton icon="fa-close" (click)="display=false" label="Cerrar"></button>
  </p-footer>
</p-dialog>
constructor(private mapService: MapService, private zone: NgZone) { }

 marker.on('click', (e) => {
          this.zone.run(() => {
            this.getInfoAlteracion(feature.properties.id_alteracion);
          });
        });
        data.push(marker);
      }