angular.js ng-repeat li items with html content

前端 未结 7 1731
挽巷
挽巷 2020-12-13 18:34

I have a model that comes back from the server which contains html instead of text (for instance a b tag or an i tag)
when I use ng-repeat to built a list out of it i

7条回答
  •  一生所求
    2020-12-13 18:55

    It goes like ng-bind-html-unsafe="opt.text":

    • {{ opt.text }}

    {{opt}}

    http://jsfiddle.net/gFFBa/3/

    Or you can define a function in scope:

     $scope.getContent = function(obj){
         return obj.value + " " + obj.text;
     }
    

    And use it this way:

  • {{ opt.value }}
  • http://jsfiddle.net/gFFBa/4/

    Note that you can not do it with an option tag: Can I use HTML tags in the options for select elements?

提交回复
热议问题