AngularJs datatable plunker not working

488 views Asked by At

I'm new to plunker/ jsfiddle and trying to create plunker of Angular Datatable Selecting rows but it is not working according to given tutorial.

Here is my plunker : https://embed.plnkr.co/1squczHPOaeHpe26zUwt/

I'm unable to find issue. Any kind of help will be appreciated.

1

There are 1 answers

0
Ovidiu Dolha On BEST ANSWER

Here is an update which solves most of your issues, which were:

  • double use of ng-app
  • missing scripts for some required libraries
  • missing module dependencies declaration
  • missing declaring controller dependencies

See https://plnkr.co/edit/AXaixxzdapWnQkjBp1bg?p=preview, some changes include:

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.13/js/jquery.dataTables.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-datatables/0.5.6/angular-datatables.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-resource/1.6.1/angular-resource.min.js"></script>

angular
  .module('showcase', ['datatables', 'ngResource'])
  .controller('RowSelectCtrl', ['$compile', '$scope', '$resource', 'DTOptionsBuilder', 'DTColumnBuilder', function ($compile, $scope, $resource, DTOptionsBuilder, DTColumnBuilder) { ...

<div ng-app="showcase">
  <div ng-controller="RowSelectCtrl as showCase">
    <p class="text-danger">You selected the following rows:</p>
    <p>
    </p><pre>{{ showCase.selected | json }}</pre>
    <p></p>
    <table datatable="" dt-options="showCase.dtOptions" dt-columns="showCase.dtColumns" class="row-border hover"></table>
  </div>
</div>