AngularJS tut 19 : API angularJS

0
0
(0)

API là viết tắt của Application Programming Interface..


API toàn cầu AngularJS

AngularJS Global API là một tập hợp các hàm JavaScript toàn cầu để thực hiện các tác vụ phổ biến như:

  • So sánh các đối tượng
  • Lặp lại các đối tượng
  • Chuyển đổi dữ liệu

Các hàm API toàn cầu được truy cập bằng cách sử dụng đối tượng góc cạnh.

Dưới đây là danh sách một số hàm API phổ biến:

APISự miêu tả
angle.lowercase ()Chuyển một chuỗi thành chữ thường
angle.uppercase ()Chuyển một chuỗi thành chữ hoa
angle.isString ()Trả về true nếu tham chiếu là một chuỗi
angle.isNumber ()Trả về true nếu tham chiếu là một số

angle.lowercase ()

Thí dụ

<div ng-app="myApp" ng-controller="myCtrl">
  <p>{{ x1 }}</p>
  <p>{{ x2 }}</p>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.x1 = "JOHN";
  $scope.x2 = angular.lowercase($scope.x1);
});
</script>

Hãy tự mình thử »



angle.uppercase ()

Thí dụ

<div ng-app="myApp" ng-controller="myCtrl">
  <p>{{ x1 }}</p>
  <p>{{ x2 }}</p>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.x1 = "John";
  $scope.x2 = angular.uppercase($scope.x1);
});
</script>

Hãy tự mình thử »

angle.isString ()

Thí dụ

<div ng-app="myApp" ng-controller="myCtrl">
  <p>{{ x1 }}</p>
  <p>{{ x2 }}</p>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.x1 = "JOHN";
  $scope.x2 = angular.isString($scope.x1);
});
</script>

Hãy tự mình thử »

angle.isNumber ()

Thí dụ

<div ng-app="myApp" ng-controller="myCtrl">
  <p>{{ x1 }}</p>
  <p>{{ x2 }}</p>
</div><script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.x1 = "JOHN";
  $scope.x2 = angular.isNumber($scope.x1);
});
</script>

Hãy tự mình thử »

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Leave A Reply

Your email address will not be published.