angular ui grid save and restore state - angularjs

I need to know how to implement save and restore state in angularui grid without using any buttons. I need to save the state automatically when ever we do any changes in the grid. We have to auto restore the saved state also. Even if we refresh the page the saved state should be restored

Here's what I figured out. I couldn't find a single event for grid state changes, but It does look like they have individual events for almost everything. Here are a few that i'm using. I just set a break point in the onRegisterApi callback and dug through the gridApi object to find the events. http://plnkr.co/edit/LAMZvOkpx6jsD4CWSz04?p=preview
HTML:
<div ui-grid="gridOptions"
ui-grid-selection
ui-grid-resize-columns
ui-grid-auto-resize
ui-grid-move-columns
ui-grid-grouping
ui-grid-save-state>
</div>
JS:
$scope.gridOptions = {
data: [
{ name: 'Jack', title: 'manager', phone: '123456789', location: 'india'},
{ name: 'Suzy', title: 'developer', phone: '465189798', location: 'usa'},
{ name: 'George', title: 'secretary', phone: '82656517', location: 'japan'},
{ name: 'Michael', title: 'analyst', phone: '31321687', location: 'egypt'},
{ name: 'Sara', title: 'consultant', phone: '59595847', location: 'germany'},
{ name: 'Chris', title: 'engineer', phone: '789456123', location: 'russia'},
{ name: 'Elizabeth', title: 'clerk', phone: '963852741', location: 'china'},
{ name: 'Jane', title: 'intern', phone: '147258369', location: 'australia'},
{ name: 'Bill', title: 'accountant', phone: '951487623', location: 'brazil'}
],
columnDefs: [
{ name: 'name' },
{ name: 'title' },
{ name: 'phone' },
{ name: 'location' }
],
enableGridMenu: true,
enableRowSelection: true,
enableRowHeaderSelection: false,
enableColumnResizing: true,
enableColumnReordering: true,
enableFiltering: true,
onRegisterApi: function(gridApi) {
// Keep a reference to the gridApi.
$scope.gridApi = gridApi;
// Setup events so we're notified when grid state changes.
$scope.gridApi.colMovable.on.columnPositionChanged($scope, saveState);
$scope.gridApi.colResizable.on.columnSizeChanged($scope, saveState);
$scope.gridApi.grouping.on.aggregationChanged($scope, saveState);
$scope.gridApi.grouping.on.groupingChanged($scope, saveState);
$scope.gridApi.core.on.columnVisibilityChanged($scope, saveState);
$scope.gridApi.core.on.filterChanged($scope, saveState);
$scope.gridApi.core.on.sortChanged($scope, saveState);
// Restore previously saved state.
restoreState();
}
};
function saveState() {
var state = $scope.gridApi.saveState.save();
localStorageService.set('gridState', state);
}
function restoreState() {
$timeout(function() {
var state = localStorageService.get('gridState');
if (state) $scope.gridApi.saveState.restore($scope, state);
});
}

Here's a service easy to use with localforage
angular.module('starter.controllers')
.factory('SaveStateGridService', function SaveStateGridService($timeout, $state, $rootScope) {
var self = {
stateName: null,
keyLocalStorage: null,
listener: null,
init: function (gridApi) {
self.stateName = $state.$current.name;
self.keyLocalStorage = 'grid-' + self.stateName;
if (self.keyLocalStorage != null) {
// save the state before we leave
self.listerner = $rootScope.$on('$stateChangeStart',
function (event, toState, toParams, fromState, fromParams, options) {
if (fromState.name === self.stateName) {
var item = gridApi.saveState.save();
localforage.setItem(self.keyLocalStorage, item);
}
self.listerner();
}
);
//restore the state when we load if it exists
localforage.getItem(self.keyLocalStorage, function (err, item) {
if (item != null) {
$timeout(function () {
gridApi.saveState.restore(null, item);
}, 1);
}
});
}
}
};
return self;
});
Controller / Component
$scope.gridOptions.onRegisterApi = function (gridApi) {
SaveStateGridService.init(gridApi);
};
Html
<div
ui-grid="gridOptions"
ui-grid-save-state></div>

it's relatively easy to save the state using Angular $cookies
function saveState() {
var state = $scope.gridApi.saveState.save();
$cookies.put('gridState', JSON.stringify(state));
}
Then, to restore:
$scope.restoreState = function() {
$timeout(function() {
var state = JSON.parse($cookies.get('gridState'));
if (state) {
$scope.gridApi.saveState.restore($scope, state);
}

I couldn't find a single event for grid state changes =>
window.onbeforeunload = function(e) {
$scope.saveState();
};
$scope.restoreState();
in case you want to reset the grid
if(localStorage.getItem("justReset")!="1")
$scope.restoreState();
localStorage.setItem("justReset","0")

Related

Get selected row of angularjs ui-grid

I've looked at multiple articles on this ui-grid and its giving me fits. I'm trying to get the selected row object. I'm either getting an undefined or can not read property of 'getSelectedRows'. Any help is greatly appreciated.
I started with this article here and the documentation doesnt seem to be all that great either.
Here is my code:
vm.gridOptions = {
enableRowSelection: false,
enableSelectAll: false,
showGridFooter:true
};
vm.gridOptions.columnDefs = [
{ name: 'productName' },
{ name: 'unitPrice' }
];
vm.gridOptions.multiSelect = false;
vm.getSelectedRows = function () {
vm.mySelectedRows = vm.gridApi.selection.getSelectedRows();
}
productDataService.getProductList()
.then(function (result) {
vm.gridOptions.data = result.data;
vm.mySelectedRows = vm.gridApi.selection.getSelectedRows();<--Property undefined error here
$timeout(function() {
if (vm.gridApi.selection.selectedRow) {
vm.gridApi.selection.selectRow(vm.gridOptions.data[0]);
}
});
});
vm.gridOptions.onRegisterApi = function(gridApi) {
vm.gridApi = gridApi;
}
Hope this helps:
angular.module('app', ['ui.grid', 'ui.grid.selection'])
.controller('MainCtrl', ['$scope', '$timeout', function($scope, $timeout) {
var vm = this;
vm.gridOptions = {
enableRowSelection: false,
enableSelectAll: false,
showGridFooter:true,
data: [{productName: "Moroni", unitPrice: 50},
{productName: "Tiancum", unitPrice: 43},
{productName: "Jacob", unitPrice: 27},
{productName: "Nephi", unitPrice: 29},
{productName: "Enos", unitPrice: 34}]
};
vm.gridOptions.columnDefs = [
{ name: 'productName' },
{ name: 'unitPrice' }
];
vm.gridOptions.multiSelect = false;
vm.getSelectedRows = function () {
vm.mySelectedRows = vm.gridApi.selection.getSelectedRows();
}
vm.getProductList = function() {
vm.gridOptions.data = vm.resultSimulatedData;
vm.mySelectedRows = vm.gridApi.selection.getSelectedRows(); //<--Property undefined error here
if (vm.mySelectedRows[0]) {
alert('Selected Row: ' + vm.mySelectedRows[0].productName + ', ' + vm.mySelectedRows[0].unitPrice + '.');
} else {
alert('Select a row first');
}
$timeout(function() {
if (vm.gridApi.selection.selectedRow) {
vm.gridApi.selection.selectRow(vm.gridOptions.data[0]);
}
});
};
vm.gridOptions.onRegisterApi = function(gridApi) {
vm.gridApi = gridApi;
};
vm.resultSimulatedData = [{productName: "Moroni1", unitPrice: 50},
{productName: "Tiancum1", unitPrice: 43},
{productName: "Jacob1", unitPrice: 27},
{productName: "Nephi1", unitPrice: 29},
{productName: "Enos1", unitPrice: 34}];
return vm;
}]);
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-grid/4.0.2/ui-grid.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/angular-ui-grid/4.0.2/ui-grid.min.css" />
<div ng-app="app" ng-controller="MainCtrl as vm">
<button ng-click="vm.getProductList()">Get Product List</button>
<div ui-grid="vm.gridOptions" ui-grid-selection class="gridStyle">
</div>
</div>
If you can share more of your code that might help me to further help you.
If you want to filter out and select a column from the selected row(s), you can run a small loop and filter the value which you require as follows:
$scope.Grid.onRegisterApi = function (gridApi) { $scope.Grid= gridApi; };
Then to a button outside the grid you can add the following method to it's ng-click event.
$scope.DoSomthing= function () {
var rows = $scope.Grid.selection.getSelectedRows();
angular.forEach(rows, function (row, key) {
angular.forEach(row, function (column, colKey) {
if (colKey == "Your Column binding string")
{
console.log(column);
}
});
});
Then probably you can create an array of the column values and use where ever you need it.
I hope this helps to anyone looking for a similar functionality !
The most easy way to get current "clicked, changed" and whatever event want is to add a cell template like this in gridOptions:
vm.gridOptions = {
enableColumnMenus: false,
enableHorizontalScrollbar: 0,
enableVerticalScrollbar: 0,
enableRowSelection: false,
enableRowHeaderSelection: false,
rowHeight: 30,
multiSelect: false,
appScopeProvider: vm,
onRegisterApi: function(gridApi) {
vm.gridApi = gridApi;
},
columnDefs: [{
{
displayName: "",
field: "delete",
enableSorting: false,
width: "80",
cellTemplate: '<div class="ui-grid-cell-contents"><span class="grid-cell-icon fa fa-trash" ng-click="grid.appScope.vm.deleteRowModal(row.entity)"></span></div>'
}
...
]
}
So row.entity is pass data from row in controller!
If you want to show grid data value from JSON and not delete icon like it is in this case put {{COL_FIELD}}
Hope now everybody can take values from cliked row from ui-grid.

Keep selection after ui-grid data refresh

I am using ui-grid in my web application.
Everything is working fine, the issue is when I refresh the grid data the selection gets removed.
In the Fiddle when I select a row and then hit the refresh the button the ui-grid selection gets removed.
JSFiddle: http://jsfiddle.net/mdawood1991/xyuotpe8/6/
HTML:
<div ng-controller="MyCtrl as controller">
<button ng-click="controller.refreshData()" type="button">
Refresh
</button>
<div ui-grid="controller.assetListGrid" ui-grid-selection></div>
</div>
Controller:
var myApp = angular.module('myApp', ["ui.grid", "ui.grid.selection"]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
myApp.controller("MyCtrl", function($scope) {
var self = this;
$scope.name = 'Superhero';
self.assetListGrid = {};
self.gridOptions = {
enableFiltering: true,
enableGridMenu: true,ang
enableColumnMenus: false,
enableRowSelection: true,
enableSelectAll: false,
multiSelect: false,
enableHorizontalScrollbar: 1,
columnDefs: [{
name: 'assetId'
}, {
name: 'reference',
enableHiding: false,
width: 250,
resizeable: true
}],
onRegisterApi: function(gridApi) {
self.assetGridObject = gridApi;
// register the onRowSelect Function here
//this.assetGridObject.selection.on.rowSelectionChanged(null, function(row) {
// if (row.isSelected)
// });
},
appScopeProvider: self
}
self.initGrid = function() {
self.assetListGrid = self.gridOptions;
self.assetListGrid.data = "controller.gridAssets"
}
self.loadInitData = function() {
self.gridAssets = [{
assetId: 1,
reference: "Dawood"
}, {
assetId: 2,
reference: "Dawood 2"
}, {
assetId: 3,
reference: "Dawood 3"
}, {
assetId: 4,
reference: "Dawood 4"
}, ]
}
self.refreshData = function() {
console.log("Data refresh")
self.gridAssets = [{
assetId: 1,
reference: "Refresh"
}, {
assetId: 2,
reference: "Refresh 2"
}, {
assetId: 3,
reference: "Refresh 3"
}, {
assetId: 4,
reference: "Refresh 4"
}, ]
}
self.initGrid();
self.loadInitData();
});
How do I keep the selection?
Seems like I have found a solution:
What I did was first I put the selected row inside a temporary object, when the row is selected
onRegisterApi: function(gridApi) {
self.assetGridObject = gridApi;
// register the onRowSelect Function here
self.assetGridObject.selection.on.rowSelectionChanged(null, function(row) {
if (row.isSelected) {
self.assetGridObject.grid.appScope.selectedRow = row.entity;
}
});
},
FIDDLE: http://jsfiddle.net/mdawood1991/02dpggyo/2/
Then when the data is refreshed I am checking if a row is selected or not, if it a row is selected I am getting the latest value of that row from the Array of new data, this what the refresh data method looks like now:
self.refreshData = function() {
console.log("Data refresh")
self.gridAssets =
[
{assetId: 1,reference: "Refresh 1"},
{assetId: 2,reference: "Refresh 2"},
{assetId: 3,reference: "Refresh 3"},
{assetId: 4,reference: "Refresh 4"}];
if (self.selectedRow)
{
console.log("Row is selected");
//THIS LINE HERE I THINK IS THE KEY -
self.assetGridObject.grid.modifyRows(self.gridAssets);
// GET THE ROW FROM NEWLY LOADED DATA
var selectedRoww = null;
for (var i = 0; i < self.gridAssets.length; i++)
{
//COMPARING BASED ON MY asseId AS THIS IS THE VALUE THAT WILL NOT CHANGE IN MY GRID - OTHER COLUMS CAN CHANGE
if (self.gridAssets[i].assetId == self.selectedRow.assetId)
{
selectedRoww = self.gridAssets[i];
}
}
// THIS LINE HERE IS SELECTING THE ROW FROM THE GRID
self.assetGridObject.selection.selectRow(selectedRoww);
}
}

Capturing checkbox values to table

I'm trying to create a form that will capture input, select and checkbox values and post them to a table. Everything seems to be working fine, with the exception of the checkboxes. What am I doing wrong?
https://jsfiddle.net/mujaji/uvkzmyox/8/
var app = angular.module("myapp", []);
app.controller("ListController", ['$scope', function($scope) {
$scope.jobtypes = ['accountant', 'janitor', 'ceo', 'receptionist'];
$scope.hobbies = [{name: "long walks on the beach", id: "1", isChecked: false},{name: "eating cheese", id: "2", isChecked: false},{name: "writing haikus", id: "3", isChecked: false},{name: "looking for bigfoot", id: "4", isChecked: false},{name: "watching police academy", id: "5", isChecked: false}];
$scope.personalDetails = [
{
'fname':'Muhammed',
'lname':'Shanid',
'jobtype': 'ceo',
'email':'shanid#shanid.com',
'active': true,
'hobbies': [{name: "long walks on the beach", id: "1"},{name: "watching police academy", id: "5"}]
},
{
'fname':'John',
'lname':'Abraham',
'jobtype': 'accountant',
'email':'john#john.com',
'active': true,
'hobbies': [{name: "writing haikus", id: "3"},{name: "looking for bigfoot", id: "4"}]
},
{
'fname':'Roy',
'lname':'Mathew',
'jobtype': 'janitor',
'email':'roy#roy.com',
'active': false,
'hobbies': [{name: "eating cheese", id: "2"}]
}];
$scope.addNew = function(personalDetails){
$scope.personalDetails.push({
'fname': personalDetails.fname,
'lname': personalDetails.lname,
'email': personalDetails.email,
'jobtype': personalDetails.jobtype,
});
$scope.PD = {};
};
$scope.remove = function(){
var newDataList=[];
$scope.selectedAll = false;
angular.forEach($scope.personalDetails, function(selected){
if(!selected.selected){
newDataList.push(selected);
}
});
$scope.personalDetails = newDataList;
};
$scope.checkAll = function () {
if (!$scope.selectedAll) {
$scope.selectedAll = true;
} else {
$scope.selectedAll = false;
}
angular.forEach($scope.personalDetails, function (personalDetails) {
personalDetails.selected = $scope.selectedAll;
});
};
}]);
The problem your facing is caused by the fact that hobbies and their checked state is outside the scope of your addNew(personalDetails) function.
Although not ideal for angular, something like this would work:
$scope.addNew = function(personalDetails) {
//get all checked hobbies
let selectedHobbies = [];
$scope.hobbies.forEach(function(hobby) {
if (hobby.isChecked) selectedHobbies.push(hobby);
});
$scope.personalDetails.push({
'fname': personalDetails.fname,
'lname': personalDetails.lname,
'email': personalDetails.email,
'jobtype': personalDetails.jobtype,
'hobbies': selectedHobbies
});
$scope.PD = {};
};
EDIT
The answer above is really a pure javascript approach to filtering by selected hobbies. A more 'angular' approach would be to break your filter logic out into its own function so that you're not mixing concerns. For example:
Add the 'filterFilter' dependency to your controller:
app.controller("ListController", ['$scope','filterFilter',
function($scope, filterFilter) { ... }
then in your controller, define an array to hold your selected hobbies and add a filter helper to filter by isChecked:
$scope.hobbiesSelection = [];
$scope.selectedHobbies = function selectedHobbies() {
return filterFilter($scope.hobbies, { selected: true });
};
place a watch on the hobbies object to watch for changes to selected hobbies:
$scope.$watch('hobbies|filter:{isChecked: true}', function (hobbies) {
$scope.hobbiesSelection = hobbies;
}, true);
and finally, you can update your addNew() method to simply be:
$scope.addNew = function(personalDetails){
$scope.personalDetails.push({
'fname': personalDetails.fname,
'lname': personalDetails.lname,
'email': personalDetails.email,
'jobtype': personalDetails.jobtype,
'hobbies': $scope.selectedHobbies
});
$scope.PD = {};
};
So while there is a bit more code (and complexity) there for this example, you are separating the logic from the data a bit better. There is working example here: https://jsfiddle.net/mt0tvkwm/

how to get a particular location on google maps with markers from a angular dropdown list

I am trying to do some location search on google maps,its like i am having a angular multi-select drop-down where i am having several locations, if i select a single location or more ,i have to show them on maps using markers,and how to get our current location any suggestions on how to do it please.
Dropdown code
<div class="m-r"
ng-dropdown-multiselect=""
options="locations"
selected-model="search.locations"
extra-settings="multiSelectSettingsFunction"
translation-texts ="locationsTexts"
settings="selectSettings">
</div>
Google maps code
<ui-gmap-google-map center="map.center" refresh="true" zoom="map.zoom" draggable="true" data-tap-disabled="true">
<ui-gmap-window show="map.window.show" coords="map.window.model" options="map.window.options" closeClick="map.window.closeClick()">
<div style="color: black" background-color="#337ab7">
{{map.window.title}}
{{map.window.venue}}
</div>
</ui-gmap-window>
<ui-gmap-markers idkey="marker.id" models="map.markers" coords="'self'" doCluster="false" fit="'true'" icon="'icon'" events="map.markersEvents " options="'options'"></ui-gmap-markers>
</ui-gmap-google-map>
controller.js
app.controller("MainController", [ '$anchorScroll', '$scope', '$http', '$modal', '$log', '$timeout', '$location', '$rootScope', '$window','$mdSidenav' , function ($anchorScroll, $scope, $http, $modal, $log, $timeout, $location, $rootScope, $window,$mdSidenav) {
$scope.searchBack = window.sessionStorage.searchBack;
$scope.search = {
pax: '',
data: '',
locations : [],
distance : []
}
$scope.$watch('search.locations', function(newVal, oldVal){
//console.log(newVal);
//$scope.setSearch();
}, true);
$scope.locationsTexts = {
buttonDefaultText: 'Locations',
dynamicButtonTextSuffix: 'Locations',
}
$scope.multiSelectSettings = {
displayProp: 'locations',
idProp: 'locations',
scrollableHeight: '256px',
scrollable: true,
enableSearch: true,
buttonDefaultText: 'asd',
dynamicButtonTextSuffix: 'Locations',
//showCheckAll: false,
};
$scope.locations = [
{id: 1, label: "kothapet"},
{id: 2, label: "Dsnr"},
{id: 3, label: "Malakpet"},
{id: 4, label: "Chadarghat"},
{id: 5, label: "Koti"},
{id: 6, label: "abids"}
];
Maps Controller
app.controller('MapController2', function($scope, $rootScope, $http) {
var data = {};
data.map = {
zoom: 16,
center: {
latitude: 17.399,
longitude: 78.52
},
markers: [
{
id: 1,
latitude: 17.3762,
longitude: 78.5461,
title: 'Location:Nagole',
venue:'Venue: Ng builders'
},
{
id: 2,
latitude: 17.3710,
longitude: 78.5410,
title: 'Location:Kothapet',
venue:'Venue: A Builders'
},
{
id: 3,
latitude: 17.3688,
longitude: 78.5247,
title: 'Location:Dilsukhnagar',
venue:'Venue: B Builders'
},
{
id: 4,
latitude: 17.3667,
longitude: 78.500,
title: 'Location:Malakpet',
venue:'Venue: C Builders'
}],
markersEvents: {
click: function(marker, eventName, model, arguments) {
console.log('Marker was clicked (' + marker + ', ' + eventName);//+', '+mydump(model, 0)+', '+mydump(arguments)+')');
$scope.map.window.model = model;
$scope.map.window.model = model;
$scope.map.window.title = model.title;
$scope.map.window.venue = model.venue;
$scope.map.window.show = true;
}
},
window: {
marker: {},
show: false,
closeClick: function() {
this.show = false;
},
options: {}, // define when map is ready
title: ''
}
};
//$scope.window = false;
$scope.onMarkerClicked = function (m) {
//this.windowOptions = !this.windowOptions;
console.log('Marker was clicked');
console.log(m);
};
$scope.closeClick = function () {
this.window = false;
};
$scope.map = data.map;
});
1) To resolve location by address name utilize Google Maps Geocoding API, for example:
var resolveAddress = function(address) {
var deffered = $q.defer();
$http({
url: 'http://maps.googleapis.com/maps/api/geocode/json?address=' + address + '&sensor=false',
method: 'GET'
}).
success(function(data) {
deffered.resolve(data);
}).
error(function(error) {
deffered.reject();
});
return deffered.promise;
};
2) For angularjs-dropdown-multiselect component you could utilize events to add events what the directive fires, for example onItemSelect which triggers once the item is selected:
<div class="m-r"
ng-dropdown-multiselect=""
options="locations"
selected-model="search.locations"
translation-texts="locationsTexts"
settings="selectSettings"
events="{ onItemSelect: showItemOnMap }">
</div>
$scope.showItemOnMap = function(item) {
//...
};
The following demo demonstrates how to display markers on map from items selected in angularjs-dropdown-multiselect control
Demo

get checkbox group values in angular watch

when tick on each checkbox, i can get all the checked values.
i want to put these values to their respective group.
here are my expected result :
{
'pattern' : ["Plain","Self Design"],
'colour' : ["Blue","Grey"]
}
im using angular $watch to get the selected values.
$scope.$watch('filters|filter:{selected:true}', function (nv, ov, scope) {
$scope.filter_selected = [];
angular.forEach(nv, function (value) {
angular.forEach(value.options, function (v, k) {
if (v.selected == true) {
this.push(v.name);
}
}, $scope.filter_selected);
});
}, true);
here is the full code in fiddle
UPDATE:
i manage to get my expected result with these code :
$scope.$watch('filters|filter:{selected:true}', function (nv, ov, scope) {
$scope.filter_selected = {pattern: [], colour: []};
angular.forEach(nv, function (value) {
if (value.name == 'pattern') {
angular.forEach(value.options, function (v, k) {
console.log(this);
if (v.selected == true) {
this.push(v.name);
}
}, $scope.filter_selected.pattern);
}
if (value.name == 'colour') {
angular.forEach(value.options, function (v, k) {
//console.log(this);
if (v.selected == true) {
this.push(v.name);
}
}, $scope.filter_selected.colour);
}
});
updated fiddle
now, how to make my checking part dynamic if i have more groups?
I have updated your code to simplify what you have above, hopefully achieving the outcome you want. I don't really think you need the watch (unless your update requirements are more complicated), but you should be able to build upon this never the less.
http://jsfiddle.net/j35zt/
The controller code was simplified as follows:
app.controller('FilterCtrl', function ($scope, $http) {
$scope.filters = [
{ name: 'pattern', placeholder: 'pattern',
options: [
{ name: 'Plain', selected: false },
{ name: 'Self Design', selected: false },
{ name: 'Check', selected: false },
{ name: 'Stripe', selected: false },
{ name: 'Print', selected: false }
]},
{ name: 'colour', placeholder: 'colour',
options: [
{ name: 'White', selected: false },
{ name: 'Blue', selected: false },
{ name: 'Grey', selected: false }
]}
];
$scope.updateOutput = function() {
$scope.filter_selected = {};
angular.forEach($scope.filters, function(f) {
$scope.filter_selected[f.name] = [];
angular.forEach(f.options, function(o){
if(o.selected){
$scope.filter_selected[f.name].push(o.name);
}
});
});
}
});
Just note, that the view also needed to be changed to match the controller. Basically ng-change is the sole cause of the updating.

Resources