I have a controller and a service. In the view i have a grid and a panel
with textboxes. On selection of a row from grid, the panel needs to be
populated with selected values. Earlier my full code was inside controller
hence it was working. Now i split them into controller and service, I do
not know how to proceed further.
Below is my approximate code, i removed unwanted lines and extra fields for
simplicity. I am getting error on selection change saying "vm is not
available". Am i doing correctly, should the gridoptions be always inside
controller function?
My view
<div class="col-xs-12" tabindex=" 0" ng-grid="vm.gridOptions" ></div>
<input ng-model="vm.item.name">
<input ng-model="vm.item.age">
My controller
function SalesController($scope, SalesService)
{
var vm = this;
vm.gridOptions = SalesService.gridoptions();
vm.item={name:'',age:''}
}
My service
function SalesService(HTTPService, config, SignalRService) {
var service = {
gridoptions: GridOptions
};
var a = {
data: 'vm.basket.Items',
enableCellSelection: false,
enableRowSelection: true,
multiSelect: false,
enableCellEdit: false,
jqueryUITheme: true,
selectedItems: [],
columnDefs:
[
{ field: 'Item.Name', displayName: 'Name', visible: true },
{ field: 'Item.Age', displayName: 'Age', visible: true }
],
afterSelectionChange: function (rowItem, event) {
console.log(rowItem.rowIndex)
vm.item = this.entity.item
}
};
return service;
function GridOptions()
{
return a;
}
}
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.