Angular SPA uygulamasında, giriş ekranı $ rootScope'ta bulunan ng-show yönerge değişkenine göre göster/gizle.Açısal JS - Sayfada gösterilen giriş ekranı Uygulamanın yenilemesi (F5)
Kullanıcı ana sayfadaysa ve sayfayı yenilerse (F5), Giriş ekranı Tamamlandı sayfası yenilenir ve kök kapsam değişkeni değeri kaybedilir.
Bu sorun nasıl giderilir?
Kod Örnek ::
<body ng-controller="mainController">
<div class="container" ng-controller="schoolLoginCtrl"
ng-show="showLogin">
<form class="form-signin" ng-submit="login()">
<h2 class="form-signin-heading">Login Page</h2>
<label for="userName" class="sr-only">User Name</label> <input
type="text" id="userName" ng-model="user.userName"
class="form-control" placeholder="User Name" required autofocus>
<label for="inputPassword" class="sr-only">Password</label> <input
type="password" id="inputPassword" ng-model="user.password"
class="form-control" placeholder="Password" required>
<div class="alert alert-danger">{{errorMsg}}</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign
in</button>
</form>
</div>
<div class="container" ng-show="!showLogin">
<div ng-view></div>
</div>
.controller('mainController', function($scope, $rootScope,
$location) {
$rootScope.showLogin = true;
});
Bu benim için çalıştı Adımları takip ettim. 1) 2) 'ngCookies' açısal modülünü ekle 3) denetleyiciye $ cookie ekleyin 4) if ($ cookies.get (' showLogin ') == undefined) { \t \t \t console.log ("güncelleştirme bilgisi"); \t \t \t $ rootScope.showLogin = $ cookies.get ('showLogin'); \t \t \t $ cookies.put ('showLogin', $ cookies.get ('showLogin')); \t \t} else { \t \t \t $ rootScope.showLogin = true; \t \t \t console.log ("çerez ekle"); \t \t \t $ cookies.put ('showLogin', true); \t \t} – Madhu