How to create angularjs filter which outputs HTML

后端 未结 3 1114
庸人自扰
庸人自扰 2020-12-13 01:14

After reading AngularJS tutorial step-9 I have created my own AngularJS filter, which should convert boolean data into html.

Here is my filter code:

         


        
3条回答
  •  伪装坚强ぢ
    2020-12-13 02:00

    unless I am reading it wrong, you are approaching in the wrong way

    I think ng-class is directive you need for this job and is safer then rendering to class attribute.

    in your case just add object string with the id strings as the class and the value as the evaluated expression

    '
    

    on a side note, you should only use directives (built-in and custom) to manipulate html/dom and if you needed a more complex html render you should look at directive instead

提交回复
热议问题