Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I have built my own backoffice control in the App_plugins.
<select ng-model="control.value.size"> <option selected="selected" value="">Choose a banner size</option> <option ng-repeat="size in bannersizes" value="{{size.value}}">{{size.name}}</option> </select>
I have populated the values using the following code:
if ($scope.control.bannersizes && $scope.control.bannersizes.length > 0) { $scope.bannersizes = $scope.control.bannersizes; } else { try { $scope.bannersizes = [ { name: 'Small', id: 'Small', selected: false }, { name: 'Large', id: 'Large', selected: false } ]; } catch (err) { alert(err.name + ': "' + err.message); } }
But when I save the control the values are not being stored and the selected values are all set to false:
$scope.$on("formSubmitting", function (ev, args) { //banner themes $scope.control.bannersizes = []; angular.forEach($scope.bannersizes, function (value, key) { $scope.control.bannersizes.push( { name: value.name, id: value.id, selected: value.selected } ); }); });
Am I missing something or am i doing it all wrong?
Thanks
Jon
Maybe try using ng-options to generate your select list rather than ng-repeat ?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Saving a selected Drop down value in AngularJS (backoffice)
Hi,
I have built my own backoffice control in the App_plugins.
I have populated the values using the following code:
But when I save the control the values are not being stored and the selected values are all set to false:
Am I missing something or am i doing it all wrong?
Thanks
Jon
Maybe try using ng-options to generate your select list rather than ng-repeat ?
is working on a reply...