输入字段值显示在所有本地浏览器实例

时间:2018-02-14 15:41:02

标签: javascript angularjs cross-browser

我在AngularJS应用程序中遇到问题,我在同一台机器上的多个浏览器的同一输入框中显示我在一个浏览器中输入的任何内容。

例如,我打开Chrome,Opera和IE11并将它们指向我的应用程序。当我开始在框中输入我的登录名时,该值将出现在所有浏览器的登录名框中。

value appearing across browsers

这只发生在我的开发机器上。当我在另一台计算机上打开应用程序时,即使在多个浏览器实例中,也不会在浏览器之间共享输入字段值。

我真的不知道这里发生了什么。我怀疑数据是在浏览器之间共享的,但我不确定如何或为什么。任何关于如何停止这一点的想法都非常感谢。

谢谢,

伊恩

以下是一些相关的代码:

vm.loginSubmit = function () {
	vm.error = null;

	vm.authService.login(vm.authRequest)
		.then(function (response) {
			vm.authService.tokenInfo = response.data;

			$window.sessionStorage.setItem("AuthenticationToken", JSON.stringify(vm.authService.tokenInfo));

			$.connection.hub.start()
				.done(function (result) {
					vm.hub.server.subscribe(vm.authService.tokenInfo.authenticationToken);
				})
				.fail(function (error) {
					vm.error = error;

				});
			

			$scope.$emit('loginNotification', vm.authService.tokenInfo);

			vm.authTokenTimerStart(vm.authService.tokenInfo.tokenExpiry);
		},
		function (error) {
			vm.authService.tokenInfo.error = error.data;
		}
	);
};
<form id="loginForm" novalidate>
	<div layout="row" ng-if="!loginPanelController.authService.tokenInfo.isAuthenticated" style="text-align: left; justify-content: flex-end;">
		<div>
			<md-input-container md-no-float>
				<input type="text" placeholder="Username" ng-model="loginPanelController.authRequest.username" />
			</md-input-container>
		</div>

		<div>
			<md-input-container md-no-float>
				<input type="password" placeholder="Password" ng-model="loginPanelController.authRequest.password" />
			</md-input-container>
		</div>

		<div>
			<md-button class="md-raised" ng-click="loginPanelController.loginSubmit()">
				<div layout="row">
					<i class="fa fa-sign-in fa-2x" aria-hidden="true"></i>
					<div>Login</div>
				</div>
			</md-button>
		</div>
	</div>

	<div layout="row" ng-if="loginPanelController.authService.tokenInfo.isAuthenticated" style="text-align: left; justify-content: flex-end;">
		<div style="align-self: center;">
			<label ng-if="!loginPanelController.authService.tokenInfo.firstName" style="margin-right: 5px; align-self: flex-end;">Hello {{loginPanelController.authService.tokenInfo.username}}</label>
			<label ng-if="loginPanelController.authService.tokenInfo.firstName" style="margin-right: 5px; align-self: flex-end;">Hello {{loginPanelController.authService.tokenInfo.firstName}}</label>
		</div>

		<md-button class="md-raised" ng-click="loginPanelController.renew()">
			<md-tooltip md-direction="bottom">
				Reset authentication timeout
			</md-tooltip>
			<div layout="row">
				<i class="fa fa-refresh fa-2x" style="margin-right: 3px;" aria-hidden="true"></i>
				<div>Renew Token ({{loginPanelController.authTokenTimeoutSeconds}})</div>
			</div>
		</md-button>
		<md-button class="md-raised" ng-click="loginPanelController.logout()">
			<div layout="row">
				<i class="fa fa-sign-out fa-2x" aria-hidden="true"></i>
				<div>Logout</div>
			</div>
		</md-button>
	</div>

	<div layout="row" class="errorMessages">
		<div ng-show="loginPanelController.authService.tokenInfo.error" style="margin-top: 0px;">
			<label>{{loginPanelController.authService.tokenInfo.error.exceptionMessage}}</label>
		</div>

		<div ng-show="loginPanelController.error">
			<label>{{loginPanelController.error.data.Message}}</label>
		</div>
	</div>
</form>

0 个答案:

没有答案