w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
angularjs - directives - determine on one directive which directive to run after by examine attribute

just for the case someone else will encounter a similar problem : my solution was writing this data on the link function and then use compile function like that:

myapp.directive('fieldDirective',['$compile', function(compile)

{
  return{
    replace : true,
    scope : {
        fieldModel: "=",
        fieldDirective: "="
    },
    link: function (scope, element, attr) {

          var strTemplate  =('<div
ng-show="fieldModel.IsRelevant"><div><div
class="fieldTitle">{{fieldModel.Title}}:</div><div><div
ng-model="fieldModel.Value" placeHolder
/></div></div></div>').replace("placeHolder",
attr.fieldDirective);
          var e = angular.element(strTemplate);
        compile(e.contents())(scope);
        element.replaceWith(e);


    },
             }
}]
);




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.