I am new with web API and angularjs.
I have a web app with login form. I have to check if the web-app is running first time in browser, but I don't know any way to do that.
Any way to check it using angularjs? Thanks in advance.
I am new with web API and angularjs.
I have a web app with login form. I have to check if the web-app is running first time in browser, but I don't know any way to do that.
Any way to check it using angularjs? Thanks in advance.
You can use cookies or local storage on the client side to store information in the browser to "know" if a user has been to the page.
https://docs.angularjs.org/api/ngCookies/service/$cookies
Doesn't appear this is really updated but believe it is a usable solution if you want to use local storage instead: https://github.com/gsklee/ngStorage
angular.module('cookiesExample', ['ngCookies'])
.controller('ExampleController', ['$cookies', function($cookies) {
// Retrieving a cookie
this.favoriteCookie = $cookies.get('myFavorite');
if(this.favoriteCookie) {
console.log('they have been here before oooo spooky')
}
// Setting a cookie
$cookies.put('myFavorite', 'oatmeal');
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.7/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.7/angular-cookies.min.js"></script>
<div ng-app="cookiesExample" ng-controller="ExampleController as exc">
{{exc.favoriteCookie}}
</div>