yu.pitomets
yu.pitomets

Reputation: 1840

Force angularjs process html

I have web app, and in this web app I have a lot generated input components. Generated components depends on user input parameter and dynamically added to web page.

One of this parameters is location picker. This is not necessary parameter so it also generated depends on user input. For location picker I use http://jsfiddle.net/mrajcok/pEq6X/ angular directive.

And my problem is when user add input, I add generated code that contains definition of ng-app, but this component does not works, because I need somehow to tell angular to parse html again. Is there are approach for that?

<div ng-app="Otd" ng-controller="SearchForm">
    <google-places location=location></google-places>
</div>

Upvotes: 0

Views: 466

Answers (1)

Manish Kr. Shukla
Manish Kr. Shukla

Reputation: 4477

You might want to use $compile service from AngularJs.

That's what is used to compile and bind dynamic HTML content to angularJS components.

And also this guide: http://docs.angularjs.org/guide/compiler

E.g. Plunker Here

  element.html(value); //Setting the HTML Content

 // compile the new DOM and link it to the current
 // scope.
 // NOTE: we only compile .childNodes so that
 // we don't get into infinite loop compiling ourselves
 $compile(element.contents())(scope);

Upvotes: 1

Related Questions