Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table id="lista-compras" class="table table-striped">
- <thead>
- <tr>
- <th sortable="nombre" class="sortable">Nombre</th>
- <th sortable="dirreccion" class="sortable">Dirreccion</th>
- <th sortable="telefono" class="sortable">Telefono</th>
- <th width="15%"> </th>
- </tr>
- </thead>
- <tbody>
- <tr grid-item class="comprado-{{ item.comprado }}">
- <td ng-bind="item.nombre"></td>
- <td ng-bind="item.dirreccion"></td>
- <td ng-bind="item.telefono"></td>
- <td>
- <button class="btn btn-despegar btn-small edit" ng-click="editarItem($index)">
- <i class="fa fa-pencil-square-o" aria-hidden="true"></i>
- </button>
- <button class="btn btn-danger btn-small" ng-click="deleteItem($index)">
- <i class="fa fa-trash-o" aria-hidden="true"></i>
- </button>
- </td>
- </tr>
- </tbody>
- </table>
- var app = angular.module('myModule', ['ui.bootstrap', 'dataGrid', 'pagination']);
- app.controller('ListaComprasController',['$scope','$anchorScroll',function($scope,$anchorScroll) {
- $scope.form = true;
- $scope.item = {};
- $scope.pagingOptions = {
- pageSizes: [5, 10, 20, 100],
- pageSize: 3,
- currentPage: 1
- };
- $scope.itens = [
- {nombre: 'Juan', telefono: 212122, descripcion: "Preuba 1",especialidades:"tarea",dirreccion:"Siempre Viva 920",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"Asesores SA",mySerNameADM:"Laz",myphoneADM:22132133,namelast:"Sergio",myphoneCOM:656565,mySerNameCOM:"Rodriguez",emailADM:"tesr@sdasad.com",checkidem:true},
- {nombre: 'Juan Jose', telefono: 3410220, descripcion: "tadsasasdas",especialidades:"tarea",dirreccion:"San Martin 555",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"Asesores SA",mySerNameADM:"Russef",myphoneADM:665+665656,namelast:"Lort",myphoneCOM:656565,mySerNameCOM:"Arenales",emailADM:"tesr@gmail.com",checkidem:true},
- {nombre: 'Pablo', telefono: 3410220, descripcion: "tadsasasdas",especialidades:"tarea",dirreccion:"Siis 64",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"Paz SA",mySerNameADM:"Perez",myphoneADM:9899878745,namelast:"Matias",myphoneCOM:656565,mySerNameCOM:"Chico",emailADM:"delivery12@gmail.com",checkidem:true},
- {nombre: 'Paulo', telefono: 3410220, descripcion: "tadsasasdas",especialidades:"Horario",dirreccion:"Viaje 4",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"Loren SA",mySerNameADM:"Matia",myphoneADM:9899878745,namelast:"Pablo",myphoneCOM:45654,mySerNameCOM:"Vaez",emailADM:"deliver231y@gmail.com",checkidem:true},
- {nombre: 'Jorge', telefono: 3410220, descripcion: "tadsasasdas",especialidades:"Venta",dirreccion:"Promo Viva 313",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"Asesores SRL",mySerNameADM:"Sam",myphoneADM:689898,namelast:"Rodrigo",myphoneCOM:545646,mySerNameCOM:"Tare",emailADM:"delivery12@gmail.com",checkidem:true},
- {nombre: 'Juan Carlos', telefono: 212122, descripcion: "tadsasasdas",especialidades:"tarea",dirreccion:"Siempre Viva 131",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"TIKI SA",mySerNameADM:"Per",myphoneADM:764876578,namelast:"Sergio",myphoneCOM:4515656,mySerNameCOM:"Stark",emailADM:"delivery23@gmail.com",checkidem:true}
- ];
- $scope.gridOptions = {
- data: $scope.itens, //required parameter - array with data
- //optional parameter - start sort options
- /*sort: {
- predicate: 'nombre',
- direction: 'asc'
- }*/
- };
- $scope.$watch(
- function() {
- return {
- currentPage: $scope.pagingOptions.currentPage,
- pageSize: $scope.pagingOptions.pageSize
- };
- },
- function(newVal, oldVal) {
- // Reset to page 1 when the page size changes
- if (newVal.pageSize !== oldVal.pageSize) {
- $scope.pagingOptions.currentPage = 1;
- }
- //$scope.fillGrid($scope.pagingOptions.currentPage, $scope.pagingOptions.pageSize);
- },
- true);
- $scope.adicionaItem = function () {
- $scope.itens.push(
- {
- nombre: $scope.item.nombre,
- telefono: $scope.item.telefono,
- descripcion: $scope.item.descripcion,
- especialidades: $scope.item.especialidades,
- dirreccion: $scope.item.dirreccion,
- horarioDesde: $scope.item.horarioDesde,
- horarioHasta: $scope.item.horarioHasta,
- checkCom: $scope.item.checkCom,
- nombreCom: $scope.item.nombreCom,
- apellidoCom: $scope.item.apellidoCom,
- telefonoCom: $scope.item.telefonoCom,
- emailCom: $scope.item.emailCom
- }
- );
- $scope.item.produto = $scope.item.quantidade = '';
- toastr.success("Item adicionado com sucesso.");
- $scope.form = true;
- };
- $scope.addItem = function () {
- $scope.form = false;
- };
- $scope.editarItem = function(index){
- $scope.form = false;
- $scope.item = $scope.itens[index];
- $scope.edit = true;
- $scope.scroll = function () {
- $anchorScroll();
- };
- };
- $scope.applyChanges = function(index){
- $scope.item = {};
- $scope.edit = false;
- $scope.form = true;
- toastr.success("Item alterado com sucesso.");
- };
- $scope.CancelarItem = function(index){
- $scope.edit = false;
- $scope.form = true;
- $scope.item = {};
- };
- $scope.deleteItem = function(row){
- var index = $scope.gridOptions.data.indexOf(row.entity);
- $scope.gridOptions.data.splice(index, 1);
- console.log(index);
- //$scope.itens.splice(index, 1);
- toastr.success("Item removido com sucesso.");
- };
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement