I'm building an AngularJS app and would like some pointers on the way I'm structuring my Angular code.

For this module, I'd like to be able to click a button that will add a Div to a specific "parent div" that has JQuery UI draggable and resizable interactions attached to it.

They could add more than one Div that is draggable and resizable.

Right now, I have one directive that generates the whole Div. The event callback for when resizing is stopped is placed in the Button that has the directive attached to it.

Directive code gist:

var app = angular.module('myApp', []); app.controller('IpadCtrl', function($scope) { $scope.someFunc = function () { console.log('resized'); alert('resized'); }; $scope.test = 'sup'; }); app.directive('addImageCont', function () { return { restrict: 'A', link: function (scope, element, attributes) { console.log(attributes); element.on("click", function() { var div = $("<div />").css({ 'width': '100px', 'height': '100px', 'background-color': 'purple' }); div.draggable(); div.resizable(); div.on('resizestop', function(event, ui) { console.log(ui); var cBack = scope[attributes.callback]; cBack(); }); element.parent().find('.ipad').append(div); }) } }; });

JSFiddle that has an example: http://jsfiddle.net/GA2M8/3/

Is this the right way to handle callback events? I'd like to be able to have a callback for when resizing begins too.

I know there's a better way to handle this.

It has been suggested to me that I break up my directives. One directive that just creates the Div and appends it to the Dom. Another directive that attaches the JQuery UI draggable interaction to it. Another directive that attaches the JQuery UI resizable interaction to it.

I'm not sure how to chain directives if that's how I should proceed.

Related news

Moda fitness certo e errado
New plymouth accommodation tripadvisor mexico
Lamarque ford facebook direct
Questionnaire on spiritual leadership definition
Adhirasam recipe by damodaran website
Petone accommodation meaning
Amsterdam self catering accommodation
Circular reasoning begging the question difference
Marquette county fairgrounds westfield wi
Fabrice pancrate martinique airport