Is there anyway to check when "/"
route is called for the first time?
I mean, check when the home page of the app is opened for the first time.
Is there anyway to check when "/"
route is called for the first time?
I mean, check when the home page of the app is opened for the first time.
Suppose you have an app that is a Single Page Application, if you want code that runs once, use module.run(): http://docs.angularjs.org/guide/module
angular.module('myModule', []).
run(function($http /*or whatever*/) {
// here goes your code that will only run at module initialization
});
You can use cookies. If user visit your app first time then he have not cookies but next time he will have.
.controller('MainCtrl', function ($scope, $cookies, $cookieStore, $log) {
$scope.showHello = !$cookies.visited;
$cookies.visited = 'yes';
});
view:
<div ng-if"showHello">
Hellow, stranger!
</div>
And don't forget to load ngCookes module angular.module('App', ['ngCookies']);