AngularJS angular.uppercase()函数用法示例

AngularJS中的angular.uppercase()函数用于将字符串转换为大写。当用户想要用大写字母而不是小写字母显示文本时,可以使用它。
语法如下:

angular.uppercase(string)

例子:在此示例中, 字符串被转换为大写。
< html ng-app = "app"> < head> < script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"> < /script> < title> angular.uppercase()< /title> < /head> < body style = "text-align:center"> < h1 style = "color:green"> lsbin< /h1> < h2> angular.uppercase()< /h2> < div ng-controller = "geek"> < br> < b> Before: < /b> {{ string1 }} < br> < br> < button id = "myButton" ng-mousedown = "upper()"> Click it! < /button> < br> < br> < b> After: < /b> {{ string2 }} < /div> < script> var app = angular.module('app', []); app.controller('geek', function($scope) { $scope.obj1 = "lsbin is the computer science portal for geeks." $scope.obj2; $scope.string1 = $scope.obj1; $scope.upper = function() { $scope.string2 = angular.uppercase($scope.obj1); } }); < /script> < /body> < /html>

输出如下:
【AngularJS angular.uppercase()函数用法示例】点击前:
AngularJS angular.uppercase()函数用法示例

文章图片
点击后:
AngularJS angular.uppercase()函数用法示例

文章图片

    推荐阅读