如何在Angular打字稿或jquery中全局更新变量。

时间:2018-02-22 05:52:04

标签: javascript jquery angular typescript variables

当我更新<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <classifier>boot</classifier> </configuration> </plugin> 时,我猜它没有全局更新,因为点击文档时它仍然显示为this.showPlan = true;而不是false

这是我的HTML代码:

true

这是我的类型脚本代码:

<li (click)="displayPlanWidget()"></li>
<div style="display: none;" id="planTabInput">----</div>

我在做错误的帮助表示赞赏。

1 个答案:

答案 0 :(得分:2)

这就是您需要实现的功能所需要的一切。 Angular建议避免直接DOM manipulation

<li (click)="displayPlanWidget()"></li> <div [hidden]="!showPlan" id="planTabInput">----</div>

import { Output, EventEmitter } from '@angular/core';

public showPlan = false;     //For showPlan
public showAccount = true; //For showAccount
@Output('activeWidget') activeWidget = new EventEmitter<string>();

public toggleWidget() {
    this.showPlan = !this.showPlan;
    this.showAccount = !this.showAccount;
    this.activeWidget.next((this.showAccount ? 'showAccount' : 'showPlan'))
}