0

html:

<div ng-dropdown-multiselect="" options="Values" selected-model="modelSelected" extra-settings="multiselectSettings" translation-texts="someCustomTexts" checkboxes="true" events="updateMultiEvents"></div>

js:

$scope.values = someData[];
$scope.modelSelected=[];

I have selected this checkbox earlier and stored model value in cookie. When i login again, all the time, this checkbox should be checked. Any idea?

Shahjahan
  • 542
  • 5
  • 12
  • Hi and welcome to SO! The code you shared doesn't seem to be enough for us to see what's wrong. You should share the code where you read the cookie you have set previously and give the model its value (if not done, you should give a try and share specific issues here, if you have some). Sharing the part where the cookie is set could be useful too. – Kaddath Apr 25 '18 at 10:25
  • Writing cookie using jquery: $.cookie("modelSelected", $scope.modelSelected, { expires: 60}); Reading cookie using jquery: $.cookie('modelSelected') When this cookie is present for the particular model, that checkbox should be selected.How could we do that in html/angualar/jquery – santhosh rajan Apr 25 '18 at 12:45

1 Answers1

0

the checkbox isn't selected because you haven't assign the cookies value to your current value. example: $scope.modelSelected = $cookieStore.get('your_stored_var_name');

Mgasmi
  • 417
  • 3
  • 13
  • $scope.modelSelected = $.cookie('modelSelected')...tried this...but it was showing as undefined and drop down shows 15 services got selected but checkboxes are not showing as seected..when i try to check the checkbox throws modelSelected.push is not a function – santhosh rajan Apr 25 '18 at 13:42
  • Have you tried to $apply() after setting the cookie ? – Mgasmi Apr 25 '18 at 16:24
  • your answer is here https://stackoverflow.com/questions/10961963/how-to-access-cookies-in-angularjs?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Mgasmi Apr 25 '18 at 16:29
  • I just put sample in jsfiddle...could you please check this one https://jsfiddle.net/yk6bnsjz/ – santhosh rajan Apr 26 '18 at 06:27
  • I see, $ is not defined, add jquery librery, example: in you html – Mgasmi Apr 26 '18 at 09:58
  • its already been added in my actual code.I just given sample logic – santhosh rajan Apr 27 '18 at 05:29