2017-09-25 118 views

回答

0

非常糟糕的想法,这是非常不安全的做到这一点。使用某种类型的服务器端语言来硬编码值,或者最好使用数据库。

但如果你只是测试,并想比较值。你可以做这样的事情......

HTML

<input type="text" #username> 
<input type="password" #password> 
<button type="submit" (click) = 'signIn(username.value, password.value)'>Add</button> 

角度成分

signIn(username:string, password:string) { 
    if(username =="your string here" && password=="your string here") 
    { 
     ///execute your code 
    } 
} 

或者只是用户名和密码的值绑定到变量您的组件和比较,当你提交。