JavaScript Adding a dynamic directive inside another directive template in AngularJS

I want to add dynamic directive inside another directive tempalte. As you see I want to add another directive inside a directive template How do add those dynamic directive there

Please help

return {
restrict: 'AE',
require :'^awkGrid',
templateUrl: 'views/shutter.html',
link : function(scope, element, attr, controllerInstance){

    //Set the header
    scope.items = [];
    angular.forEach(scope.rowData, function(value, key) {

        var obj = {
            key : key,
            value : value
        };


        template = <country name="'+value.country+'" id="'+key+'"></country>;
        scope.items.push(template);
    });
};
//Inside shutter.html file
 <div data-ng-repeat="item in items" class="ag-row action-row"
 ng-class-odd="'ag-row-even'"
 ng-class-even="'ag-row-odd'"
 ng-class="{'ag-row-selected':$index == selectedRow}"
 ng-click="setClickedRow($index,$event)">
<div class="ag-cell">
            {{item}} //Not working ,Prinitng the string
    <country name="india" id="-1"></country> //Working
</div>

Answer:1

To dynamically switch out the entire template of a directive you have to set the element's html to the desired new template and then pass the element's contents into $compile to bind it with the $scope.

element.html('<h1>Dynamic Content</h1>').show();

$compile(element.contents())($scope);

This should all be defined in the link function of the directive in question.

Answer:2

I have read several tutorials about closures. Some tutorials have some information about execution context. I am confused that execution context and closure seem to the same thing.Does anyone can ...

I have read several tutorials about closures. Some tutorials have some information about execution context. I am confused that execution context and closure seem to the same thing.Does anyone can ...

  1. closure execution context

I have a ScatterChart where I need to draw a diagonal line (of the function y=x) that serves as a visual aid. Is it possible ? if so, how can I do it?

I have a ScatterChart where I need to draw a diagonal line (of the function y=x) that serves as a visual aid. Is it possible ? if so, how can I do it?

  1. draw line google maps
  2. draw line google docs
  3. draw line google earth pro
  4. draw line google maps api
  5. draw line google maps javascript
  6. draw line google maps between two points
  7. draw line google earth
  8. draw line google maps android
  9. draw line google maps coordinates
  10. draw line google sketchup
  11. line draw google chart
  12. draw latitude line google maps
  13. draw straight line google maps
  14. draw line distance google maps
  15. draw dashed line google maps android
  16. draw latitude line google earth
  17. draw a line google
  18. draw straight line google earth
  19. draw a line google maps ios
  20. google maps draw polyline

I'm really confused about importing a VueJs component. I'm using Vuejs 2.2.4, and I need to import a Vuejs component. Here is my app.js: Vue.component('Test', require('./Test.vue')); const app = ...

I'm really confused about importing a VueJs component. I'm using Vuejs 2.2.4, and I need to import a Vuejs component. Here is my app.js: Vue.component('Test', require('./Test.vue')); const app = ...

  1. dynamic import component vuejs
  2. import multiple components vuejs
  3. import css in component vuejs
  4. vuejs import component global
  5. vuejs import component without webpack
  6. vuejs import component webpack
  7. import component in another component vuejs
  8. vuejs import component unexpected identifier

I have an angular dropdown problem. I want to show projects with ng-repeat with dropdown selected value and split them into range. can anybody help me please? jsfiddle : http://jsfiddle.net/...

I have an angular dropdown problem. I want to show projects with ng-repeat with dropdown selected value and split them into range. can anybody help me please? jsfiddle : http://jsfiddle.net/...

  1. angularjs search filter multiple parameters
  2. angularjs search filter example
  3. angularjs search filter dropdown
  4. angularjs search filter select options
  5. angularjs search filter on specific field
  6. angularjs search filter table
  7. angularjs search filter with pagination
  8. angularjs search filter example jsfiddle
  9. angularjs search filter
  10. angularjs search filter table example
  11. angularjs search filter in controller
  12. angularjs search filter w3schools
  13. angularjs search filter not working
  14. angularjs search filter by property
  15. angularjs search filter date
  16. angularjs search filter function
  17. angularjs search filter array
  18. angularjs search filter ng repeat
  19. angularjs search filter is slow
  20. angularjs search filter count