In dieser AngularJS Anwendung ich eine Login-Seite zunächst, wo der Benutzer Benutzernamen und Passwort. Sobald sie in der Anwendung sind, können sie eine andere Seite wählen, die einen anderen Benutzernamen und ein anderes Passwort für den Datenbankzugriff benötigt. Ich möchte, dass der Benutzername der Datenbank auf einen anderen Wert als der Benutzername und das Kennwort zurückgesetzt wird, das mit einem Platzhalter Enter a password
leer sein soll. Die Standardwerte auf der Datenbankseite verwenden jedoch die anfänglichen Anmeldewerte.
Dies ist der HTML-Code der Login-Seite:Standardwerte sind falsch in HTML Winkel Anwendung
<div class="form-group">
<label for="username" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="username" name="username" placeholder="Username" style="width: 80%" autofocus ng-model="credentials.username" />
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="password" name="password" placeholder="Password" style="width: 80%" ng-model="credentials.password" />
</div>
</div>
Dies ist der HTML-Code der Datenbank Login:
<div class="row" style="margin-top: 10px; margin-bottom: 10px;">
<label id="inputDBUserNameLabel" style="margin-left: 10px;" >User Name: </label>
<input id="inputDBUserNameText" type="text" ng-model="inputUserName" class="form-control demoInput" value="test" style="margin-left: 5px; width: 25%;"/>
</div>
<div class="row" style="margin-top: 10px; margin-bottom: 10px;">
<label id="inputDBPasswordLabel" style="margin-left: 10px;" >Password: </label>
<input id="inputDBPasswordText" type="password" ng-model="inputPassword" class="form-control demoInput" placeholder="Enter a password" style="margin-left: 5px; width: 25%;"/>
</div>
Was mache ich falsch?
UPDATE Unten ist der Code zu meinem Controller bei der Verbindung mit der Datenbank.
Wenn der richtige Benutzername und Passwort eingeben es funktioniert:
'use strict';
angular.module('vow-administration-ui')
.controller('UpgradeCtrl', ['$scope', 'UpgradeDB',
function($scope, upgradeDB) {
$scope.title = "Upgrade Database";
$scope.inputServerName = '';
$scope.inputDatabaseName = '';
$scope.inputUserName = '';
$scope.inputPassword = '';
$scope.outputServerName = '';
$scope.outputDatabaseName = '';
$scope.outputUserName = '';
$scope.outputPassword = '';
$scope.UpgradeDatabase = function(){
upgradeDB.save({
inputServerName: $scope.inputServerName,
inputDatabaseName: $scope.inputDatabaseName,
inputUserName: $scope.inputUserName,
inputPassword: $scope.inputPassword,
outputServerName: $scope.outputServerName,
outputDatabaseName: $scope.outputDatabaseName,
outputUserName: $scope.outputUserName,
outputPassword: $scope.outputPassword
}).$promise.then(function(response) {
var responseText = response;
console.log(responseText);
});
};
}]);
UPDATE Ich entfernte die ng-model=inputUserName
und sowohl die Felder Benutzername und Passwort wurden den erwarteten Werten geändert. Das ist das Feld Benutzername den Standardwert von test
hatte und das Feld Kennwort hatte den Platzhalter von Enter a password
obwohl ich das ng-model
Attribut aus dem Passwort-Feld nicht entfernen Sie.
UPDATE Anmeldung Controller:
angular.module('vow-administration-ui')
.controller('LoginCtrl', function($scope, $rootScope, $location, AUTH_EVENTS, AuthService) {
$scope.isProcessing = false;
$scope.credentials = {
domain: '',
username: '',
password: ''
};
$scope.login = function() {
AuthService.authenticateAdministrator($scope.credentials).then(function() {
$scope.errorMessage = '';
$scope.errorState = false;
$location.path('/launch').replace();
},
function(error) {
AuthService.destroyToken();
$scope.errorMessage = 'Failed to authorize. ' + error.data.ExceptionMessage;
$scope.errorState = true;
});
};
});
Es muss etwas in Ihrem Controller geschehen (imo). Können wir es sehen? – defaultcheckbox
Ich habe den Controller für die Datenbankanmeldung hinzugefügt. –
hmm .. scheint mir gut. Kannst du eine JSBIN oder Plunkr machen? Ich bin mir nicht sicher, warum inputUserName den gleichen Wert wie credentials.username haben würde. Vielleicht verstehe ich deine Frage falsch? Ich denke, ein JSBIN oder Plunkr würde helfen, das Problem zu klären. – defaultcheckbox