my_app.run( [ '$templateCache' , function( $templateCache ) {
var template = "" +
"{{ item.name }}" +
"<ul ng-if='item.sub'>" +
"<li ng-repeat='item in item.sub' ng-include=\"'angular-multi-select-item.htm'\"></li>" +
"</ul>" +
"";
$templateCache.put( 'angular-multi-select-item.htm' , template );
}]);
While this works as expected, I see it quite ugly (the concatenated string with html inside). Is there some other, more clean, way to define the html for an Angular template?
What you think about this? Just create a view html view file in your working directory and load it with $http.
$templateCache.put('angular-multi-select-item.htm', $http.get('views/template.html'));
Your can also try it with `ng-include? (documentation) and add includes in the main view like:
<div ng-include="'views/template.html'"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With