javascript - View from multiple partials (loaded dynamically) in angular.js -


i create view consisting of multiple partials loaded dynamically depending on content type. new angular.js, , idea have in controller:

$(elem).html(string_with_src); $compile(elem.contents())($scope); 

...and works. thing wanted put source of partials in separate files , load them through jquery:

$.get(source.html, function( data ) {   elem.html( data );   $compile(elem.contents())($scope); }); 

but doesn't work. template not compiled angular.js. explain me why doesn't work or how better?

don't use jquery this.

angular provides directive load partials: ng-include:

<div ng-include="'/path/to/partial.html'"></div> 

(notice double quotes "' when passing static string)

you use dynamic path:

$scope.pathtopartial = "/path/to/partial/" + partialname + ".html";  <div ng-include="pathtopartial"></div> 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -