How to drag&drop elements onto a calendar with angular directives only

前端 未结 2 1361
清歌不尽
清歌不尽 2021-01-03 07:56

I am trying to implement a drag&drop calendar with angular directives. The calendar uses the ui-calendar (https://github.com/angular-ui/ui-calendar), a complete AngularJ

2条回答
  •  臣服心动
    2021-01-03 08:59

    Another way to accomplish this is use JqueryUI draggable. Create directive and pass the attributes via "elem". You can include title as an attribute as well.

    .directive('dragMe', function() {
      return {
        restrict: 'A',
        link: function(scope, elem, attr, ctrl) {
          elem.data('event', {
              title: $.trim($(elem).text()), // use the element's text as the event title
              stick: true // maintain when user navigates (see docs on the renderEvent method)
            });
          elem.draggable({
              zIndex: 999,
              revert: true,      // will cause the event to go back to its
              revertDuration: 0  //  original position after the drag
            });
        }
      };
    })

提交回复
热议问题