简体   繁体   中英

Populate username in IdentityServer login page with default value

<form>
    <fieldset>
        <div class="form-group">
            <label for="username">Username</label>
            <input required name="username" autofocus id="username" type="text"   class="form-control" placeholder="Username"   contenteditable="true"  ng-model="model.username" value="MyDefaultValue" maxlength="100">
        </div>
        <div class="form-group">
            <label for="password">Password</label>
            <input required id="password" name="password" type="password" class="form-control" placeholder="Password" ng-model="model.password" maxlength="100" autocomplete="off">
        </div>
        <div class="form-group">
            <button class="btn btn-primary" ng-disabled="form.$invalid">Login</button>
        </div>
    </fieldset>
</form>

I wanted "MyDefault" value to be displayed in the login screen as Username value but I can't see any value in login screen.

**value="{{model.loginUrl}}"** ng-model="model.username" **value="MyDefaultValue"**

You have double value attribute here. You should delete first one if you would like to show MyDefaultValue.

可以添加这个 (ng-init="model.username = model.username || 'MyDefaultValue'") 如果它在那里,它将采用任何一个 model.username nd 因为第一次 model.username 是 null ,它会取值为“MyDefaultValue”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM