角JS - 返回如HTML字符和放大器的字符串; NBSP; [英] Angular js - Return a string with HTML characters like  

查看:180
本文介绍了角JS - 返回如HTML字符和放大器的字符串; NBSP;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个过滤器只是一个数值后面加一个antislash如果另一个给定的值是不是空的,我想从字符串的其余部分本antislash与&放大器分开; NBSP;
实际上,过滤器本身工作,但正确的字符串 如在该网页。

I made a filter just to add an antislash after a value if another given value is not empty and I would like to separate this antislash from the rest of the string with   . Actually the filter itself work but right the string " " as is in the page.

angular.module('ngMod', []).
filter('antislash', function() {
  return function(input) {
    if( input==null || input.length === 0 ){
      return null;
    }else{  
      return ' / '; 
    }
  }
});

它显示在页面:&放大器; NBSP; /&安培; NBSP;

确实存在一个HTML过滤器或等同的东西吗?

Does exist an html filter or something equivalent ?

推荐答案

它通过赋予 UNI $ C $ç获得价值&放大器; NBSP;

angular.module('ngMod', []).
filter('antislash', function() {
  return function(input) {
    if( input==null || input.length === 0 ){
      return null;
    }else{  
      return '\u00A0/\u00A0'; 
    }
  }
});

您也可以使用 $的sanitize NG-绑定-HTML NG-结合HTML的不安全输出HTML snipets。

You can also use $sanitize with ng-bind-html and ng-bind-html-unsafe to output html snipets.

这篇关于角JS - 返回如HTML字符和放大器的字符串; NBSP;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆