And here is the complete implementation of the widget directive. I modified 
it in my previous post to make it more simple... unfortunately it made it 
confusing cause i looped thru all widgets available, instead just putting 
the one together what I want...

.directive('dashboardWidget', function($compile) {
    return{
      restrict: 'E',
             scope: {
        type: '@' // type parameter
      },
      controller: function($scope, $element) {
        // get available widgets and the widget we want to display (type 
parameter)
        var widgets=require('./dashboard-widgets/dashboard-widgets'), // 
here the widgets were defined
            type=$scope.type; // type parameter

        // check if widget exists
        if (typeof(widgets[type])=='object') {
          var widget=widgets[type];
          // set title
          $scope.title=widget.name;
          $scope.widgetKey=type;
          $scope.widgetParams={};
          if (typeof(widget.params) == 'object' && widget.params) {
            $scope.widgetParams=widget.params;
          }

          // append the directive of the appropiate widget in to the 
containers html... (using jQLite)
          var el=$compile('<dashboard-widget-' + widget.widget + ' 
widget-params="widgetParams"></dashboard-widget-' + widget.widget + 
'>')($scope);
          var divs=$element.find('div');
          for (var i=0; i<divs.length; i++) {
            var div=angular.element(divs[i]);
            if (div.hasClass('widget-content')) {
              div.append(el);
            }
          }
        }
      },
      template: require('./dashboard-widget-container.html')
    }



Am Donnerstag, 12. Februar 2015 09:43:00 UTC+1 schrieb Sander Elias:
>
> Hi Jan,
>
> Just out of curiosity, how does your template look like? I don't get that.
> You are iterating over your widgets, that's easy enough, but then for each 
> widget you are iterating over all div's and and every widget to every div 
> that has .widget-content.
> I can't imagine how that turns out.
>
> Regards
> Sander
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to