简体   繁体   中英

Angular js - Return a string with HTML characters like  

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 ' / '; 
    }
  }
});

It displays in the page :  / 

Does exist an html filter or something equivalent ?

It works by giving the unicode value for   .

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM