0

I have the following ui-router configuration in my angular app:

app.config(["$stateProvider", function ($stateProvider) {
  $stateProvider
    .state("state1", {
      controller: "controller",
      templateUrl: "mytemplate.html"
    })

app.controller("controller"....

In the controller I call a google cloud endpoint API:

gapi.client.myapi.method().then(function (resp){

}, function (error) {

});

How can I add html using the data from the API response? Is using a directive the best approach?

UPDATE:

I forgot to mention that the response is from an insert method, this means that this will be executed several times, and each time I need to add the response to the existing elements, like in a timeline way.

rena
  • 1,223
  • 3
  • 17
  • 30

1 Answers1

0

You can use ngBindHtml incase your response is HTML or bind the response to your template using {{variableName}} inside your mytemplate.html

Directives are preferred if that piece of code is to be used in multiple screens and is also a good practice for big projects.

Thanks, Abhishek Jain.

abhishekdgeek
  • 41
  • 1
  • 7