单向出价不会使用控制器更新模板

时间:2019-02-09 23:03:57

标签: angular ionic-framework

我正在尝试通过切换字符串参数的值来更改按钮的值。

这是我的html文件中的声明:

<app-connexion *ngIf="connexionVisible"></app-connexion>
<app-inscription *ngIf="!connexionVisible"></app-inscription>

<ion-button (click)="toggleInscription()">{{status}}</ion-button>

这是我的控制器:

export class LoginComponent implements OnInit {

  connexionVisible: boolean = true;
  status: String = "Inscription";

  constructor() {}

  ngOnInit() {}

  toggleInscription() {

    (this.connexionVisible) ? this.connexionVisible = false:
      this.connexionVisible = true;
    (this.status = "Inscription") ? this.status = "Connexion": this.status =
      "Inscription";
  }

}

它仅在我第一次切换按钮然后保持“ Connexion”不变时才起作用,而我的由布尔条件限制的组件则表现得非常好。我不明白。

1 个答案:

答案 0 :(得分:1)

您的代码有问题。

  

您使用的是assignment(=)运算符,而不是equality(===)运算符。

尝试解决此问题:

var getMyDbInfo = function(callback) {
    var db = new sqlite3.Database("MyDB.sqlite3");

    var myJsonObj = {};

    db.each("select * from Table1",
        function(err, row) {
            console.log("\n---- 0 ----\n");
            // calculate doorId from row
            doorId = ...

            db.all("select * from Table2 where ID=" + doorId,
                    function(err, row2) {
                        console.log("---- 6 ----\n");
                        if(err) {
                            console.log("-- ERR: " + err);
                        } else {
                            console.log(row2);
                            var myJsonElem = {ID:row.ID,
                                DoorName: row2.DoorName,
                                TimeSpec: row2.TimeSpec };

                            myJsonObj.data.push(myJsonElem);
                        }
                    }
            );
        },
        function (err, rows) {
            callback(null, myJsonObj);
            db.close();
            console.log("---- 10 ----\n");
        }
    );

};