1
簡単な質問。Aurelia - テンプレートの変数にアクセスできません
<template>
<section>
<h2>${heading}</h2>
<form role="form" submit.delegate="login()">
<div class="form-group">
<label for="userName">User Name</label>
<input type="text" value.bind="userName" class="form-control" id="userName" placeholder="User Name">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" value.bind="password" class="form-control" id="password" placeholder="Password">
</div>
<button type="button" click.delegate="submitLogin()" class="btn btn-default">Login</button>
</form>
<hr>
<div class="alert alert-danger" if.bind="loginError">${loginError}</div>
</section>
私は私login.tsファイルでこれらの変数にアクセスする方法を見つけるために周りを見回している:ユーザー名とパスワードを入力するためのフォーム -
は私がログインテンプレートを持っています。
特に、ボタンのログインを押すと、最終的にAPIに送信します。
私はsubmitLogin()関数を持っていますが、変数のユーザー名とパスワードへのアクセス方法はわかりません。
これらの変数にアクセスする方法を誰かに教えてもらえますか。私は、ユーザー名とパスワードの赤のアンダースコアを取得
..
import { HttpClient } from "aurelia-fetch-client";
import { autoinject } from "aurelia-framework";
import { TokenService } from "../tokenService";
@autoinject
export class Login {
http: HttpClient;
tokenService: TokenService;
heading = "Login";
constructor(tokenService: TokenService, http: HttpClient,) {
this.tokenService = tokenService;
this.http = http;
}
public submitLogin(): void {
console.log("userName, Password", this. userName, this.password);
}
}
Excel貸してください。これは本当に簡潔な答えでした。ありがとうございました – si2030