Is there a way to get transform with template to html?

54 views Asked by At

I am using bootbox, I need display product information in it. The product information is returned as json with rest call. I am thinking using a template, and transform from the json to html. I need ng-repeat etc, in the template. The idea way is I can call template and get a html result.

But it seems angularjs $compile need bind to element to render. any idea?

1

There are 1 answers

1
Faly On

I think you can use ng-include:

var app = angular.module('myApp', []);
app.controller('productCtrl', function($scope) {
  $scope.productInfos = [];
});

Use ng-include (You have to the adjust the path depending the location of your template)

<div ng-app="myApp" ng-controller="productCtrl"> 
  <div ng-include="'product-information.html'"></div>
</div>   

You can do ng-repeat in product-information.html:

<div ng-repeat= "info in  productInfos"> {{ info.prop1 }}</div>