1

righ now my code in html looks like this and it dont print the things i wanna print

 <tr ng-repeat="i in info | filter:search | orderBy: order">
  <td >{{$index + 1}}</td>
  <td>{{i.username}}</td>
  <td>{{i.price}}{{i.edit_able}}</td>
  <td>{{i.min_amount}}-{{i.max_amount}}</td>
  <td><a href="<?php echo URL;?>ad/show/{{i.ad_id}}">View</a></td>
 </tr>

my angular code for edit able is

if(edit_able != false){
 $scope.info[i].edit_able =  [{html:'<a href="#" ng-click="editorEnabled=!editorEnabled">Edit price</a>'}];
}else{
  $scope.info[i].edit_able = '';
}

i wanna print out this in html and not as a html escape string

1 Answer 1

1

If you pass HTML this way it has to be added to view by ng-bind-html and before it has to be sanitised with $sce but your problem is trivial really, you can just use ngIf to display the a tag only when necessary

 <tr ng-repeat="i in info | filter:search | orderBy: order">
  <td >{{$index + 1}}</td>
  <td>{{i.username}}</td>
  <td>{{i.price}}<a ng-if="i.edit_able" href="#" ng-click="editorEnabled=!editorEnabled">Edit price</a></td>
  <td>{{i.min_amount}}-{{i.max_amount}}</td>
  <td><a href="<?php echo URL;?>ad/show/{{i.ad_id}}">View</a></td>
 </tr>
Sign up to request clarification or add additional context in comments.

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.