angularjs - angular-drag-and-drop-lists simple demo doesn't work -


i having problem getting simple demo work found here.

i'm getting 2 lists show up, unable drag , drop items. demo simple, html file, javascript file , css file.

here's index.html file:

<!doctype html> <html ng-app="demo"> <head lang="en">     <meta charset="utf-8">     <title>drag & drop demo</title>      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>     <script src="bower_components/angular-drag-and-drop-lists/angular-drag-and-drop-lists.min.js"></script>     <script src="scripts/my-app.js"></script>     <link href="content/my-styling.css" rel="stylesheet" /> </head> <body class="simpledemo" ng-controller="simpledemocontroller">     <ul dnd-list="list">         <li ng-repeat="item in models.lists.a"             dnd-draggable="item"             dnd-moved="models.lists.a.splice($index, 1)"             dnd-effect-allowed="move"             dnd-selected="models.selected = item"             ng-class="{'selected': models.selected === item}">             {{item.label}}         </li>     </ul>      <ul dnd-list="list">         <li ng-repeat="item in models.lists.b"             dnd-draggable="item"             dnd-moved="models.lists.b.splice($index, 1)"             dnd-effect-allowed="move"             dnd-selected="models.selected = item"             ng-class="{'selected': models.selected === item}">             {{item.label}}         </li>     </ul> </body> </html> 

here's js file:

angular.module("demo", []).controller("simpledemocontroller", function ($scope) {      $scope.models = {         selected: null,         lists: { "a": [], "b": [] }     };      // generate initial model     (var = 1; <= 3; ++i) {         $scope.models.lists.a.push({ label: "item a" + });         $scope.models.lists.b.push({ label: "item b" + });     }      // model json demo purpose     $scope.$watch('models', function (model) {         $scope.modelasjson = angular.tojson(model, true);     }, true);  }); 

and here's css file:

.simpledemo ul[dnd-list], .simpledemo ul[dnd-list] > li {     position: relative; }  .simpledemo ul[dnd-list] {     min-height: 42px;     padding-left: 0px; }  .simpledemo ul[dnd-list] .dnddraggingsource {     display: none; }  .simpledemo ul[dnd-list] .dndplaceholder {     display: block;     background-color: #ddd;     min-height: 42px; }  .simpledemo ul[dnd-list] li {     background-color: #fff;     border: 1px solid #ddd;     border-top-right-radius: 4px;     border-top-left-radius: 4px;     display: block;     padding: 10px 15px;     margin-bottom: -1px; }  .simpledemo ul[dnd-list] li.selected {     background-color: #dff0d8;     color: #3c763d; } 

this code copied , pasted simple demo, modified show lists , b. know what's wrong?

you're forgetting dependency injection replace

angular.module("demo", []) 

with

angular.module("demo", ['dndlists']) 

and should work..

plunk

--update--

i found problem markup referencing list in <ul dnd-list="list>" not work you're referencing undefined variable, should referencing list using in drag-able. example first list can change.

<ul dnd-list="list"> 

to

<ul dnd-list="models.lists.a"> 

and should work now..

p.s i've updated plunk


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -