I am now since my last attempt is unresolved trying a different way to do 
dynamic templating based on some new code and blog 
here http://onehungrymind.com/angularjs-dynamic-templates/
Thanks for that lucas - again it isnt quite what I need to do but it has 
allowed me to try and do things a bit differently.
So I now have template strings from json that I am pulling in depending on 
UI so that it happens after bootsrap..and first run etc

My issue is that running this part of my directive
        scope.changeTemplate = function(t){

            var template = '',
                type=t;

            TemplateService.getTemplates().then(function (response) {
                var templates = response.data;
                scope.htmlString = templates[type];
                //compile is causing us to loose our original modal markup 
- its too heavy a hammer !
                //we want to append this markup and apply perhaps ?
                element.html(templates[type]);
                $compile(element.contents())(scope);
            });

        }
this removes my markup during the compile even though replace is false in 
this directive. I have tried [append] but then it doesn't add the html in 
the right place - JQuery could brute force it but I am trying not to use 
that kind of thing..I am trying not to load JQuery at all in fact.

This directive is a modalpopup and has initial markup and I tried 
previously to simply use bind html - on the internal element where I want 
my injected dynamic code.

<div class="modal" ng-controller="ModalCtrl">
  <input class="modal-state" id="modal-1" ng-model="checkboxModalModel" 
type="checkbox"/>
  <div class="modal-fade-screen" ng-click="closeModal($event)">
    <div class="modal-inner">
      <div class="modal-close" for="modal-1" 
ng-click="closeModal($event)"></div>
      <h1>{{title}}</h1>
      <!--<div my-youtube code="code"></div>-->
      <p class="modal-content" ng-bind-html="htmlString">
      </p>
    </div>
  </div>
</div>

So ng-bind-html="htmlString" is so easy and works if it was compiling at 
runtime. What I guess I want to do is something less than
element.html(templates[type]);
$compile(element.contents())(scope);

but that can make the angular parse the html...

Thanks for advice.


-- 
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