AngularJs 大写过滤器uppercase介绍和用法示例

2021年3月15日09:18:43 发表评论 726 次浏览

大写过滤器在AngularJS中用来将字符串更改为大写字符串或字母.

语法如下:

{{ string | uppercase}}

例子:

<!DOCTYPE html>
< html >
  
< head >
     < title >
       uppercase Filter
   </ title >
     < script src =
"https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js" >
     </ script >
</ head >
  
< body ng-app = "app"
       style = "text-align:Center" >
    
     < h1 style = "color:green" >
       lsbin
   </ h1 >
     < h2 >
       uppercase Filter
   </ h2 >
     < div ng-controller = "geek" >
         < p >
             < span style = "color:green" >
               {{msg | uppercase}}
           </ span > is the computer 
           science portal for geeks.
             < p >
     </ div >
     < script >
         angular.module('app', [])
             .controller('geek', ['$scope', function($scope) {
                 $scope.msg = 'lsbin';
             }]);
     </ script >
</ body >
  
</ html >

输出如下:

大写

木子山

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: