0

I have problem with my ionic app. My application connect to server via $.http (GET or POST). When script success download data, I display it on

{{data.description}}

My problem is when data.description have url's. When in my db description have link


edit

When I use this method:

.success(function(data){
  // data.description = test(data.description);
  $scope.task = data;
  $rootScope.MyData = {
    description : '<a href="http://google.com"> dasd</a>' 
  }
})

or

 $scope.task = data;
      $rootScope.MyData = {
        description : data.description 
      }

and in html:

 {{MyData.description}}

I still have this problem: enter image description here

1

2 Answers 2

1

Use $rootScope

$http.get(...).then(function (response) {
    $rootScope.MyData = {
        description : data.description
    }
}, function (response) {

);

Your Html

<a class="button button-clear button-positive" 
href="{{MyData.description}}">dasd</a>

Note: MyData.description = http://google.com

Sign up to request clarification or add additional context in comments.

1 Comment

I try to use it and I still have problem, If you can plase see edit :)
0

It's because Angular escapes the html that's within the curly brackets. You can use ngSanitize in combination with ngBindHtml directive. So your code would be like:

<p ng-bind-html="MyData.description"></p>

Don't use an <a> tag for this because the directive will place the html inside whatever tag you use.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.