How to store the cookies from one session and restore the same cookies by refreshing the page in AngularJS? - angularjs

I have two input item one for the Option Select and Radio Button. Once the user selects the Option Select (say, the value is ABCD) and Radio button (say, the value is R).
Now the user refreshes the page and would like to pre-populate the page with a default value of Option Select (ABCD) and radio button (R).
I have been trying to use ngCookies. I can set and get the cookies from the same session. Once I refresh the page, the values become null.
such as $cookies.put('selectOption', $scope.selectValue) $cookies('radioSelection', $scope.radioValue)
TO get the value, $cookie.get('selectOption') and $cookie.get('radioSelection');
Basically, recreating the page with some default values.
Please help me out how I can achieve this one.

I guess you are resetting your select box value each time you refresh so add an if statement like
if (!$cookie.get('selectOption') ) {
$cookies.put('selectOption', $scope.selectValue)
}

Related

I am creating multiple user in Django site

register form select user then automatically show user header id
how to get selected data in form before submit
how to check a condition selected user = header and get value in Django
view function work but how to get form data in before submit in template

How to retrieve data from different page angular

I have a button in the table in the first page. When I click on the button, I want to save the panel Id and display on the next page. How can I call the data in angular? I'm desperately seeking for help since I'm stuck in there for almost a week now.
These are the images for my problem.
enter image description here
So this one is the first page, where there are buttons in each row.
After clicking Assign, it should show readonly data of ship name and panel name.
enter image description here
Regarding your issue, you should get the panel_id from params in the URL.
E.g.
In the routing of the assigning page, you just set the path:
{
path: 'assigning/:id',
component: <YourComponent>
}
So you can get the panel_id by using ActivatedRoute.
On click event of "Assign" button, you can pass the value to the ts component. In the ts file you can pass it via URL route as a parameter to the next page or store it in localStorage and read from the next page.
<button (click)="passValue(value)">Assign</button>

Set a variable to null whenever a user clicks the back button to a particular page in ionic

I am trying to set a variable to set a variable to null whenever a user clicks the back button after signing in. So I am doing this but it is not working as the variable still shows on that Page which is the signin page
var currentUserNow = localStorage.getItem("username")
alert(currentUserNow);
localStorage.removeItem("userDetail");
localStorage.removeItem("username");
$urlRouterProvider.otherwise('/sign-in');
Now I want to ask is there anyhow I can tell that the user has clicked the back button to a particular page and set that variable to null
if you are trying to disable the back button in login page.
then try in login.html
<ion-content hide-back-button="true">

Drupal Webform - How to load values from form, filled in a previous page

Working on Drupal, I have a page with a form made with "Webform" module, containing several fields (text fields and sliders) and a "Submit" button.
When the user enters the information and presses the "Submit" button, another page is loaded with custom code into it.
The new page is devided into 2 parts - the first one contains new information(based on the user input from the previous page); the second one contains (block) the same form, used in the previous page.
Is there a way to load the values, filled in the form from the first page into the new page?
First of all you would need to make a custom module, with the help of
hook_form_alter
You would need to store the previous form's information in cookies with prefix
Drupal_visitor_
and then display it in the new page like:
$form['submitted']['FirstName']['#default_value'] =
$_COOKIE[$firstname];
Thanks

how to set pagingtoolbar input item value

I have a problem here.
I bind a store on the pagingtoolbar which has more than one page. For example I change current page to the page 2, then I change the store content which has only one page by a search form . The grid loads the collect data, but the input item still shows that it's in page 2, where I want it to show 1 after I call the search event.
I don't want to use store.loadPage(1) because this will cause one more exchange between the server, can anyone helps me?
Try this:
grid.store.currentPage = 1;
grid.down('pagingtoolbar').onLoad();

Resources