>  기사  >  웹 프론트엔드  >  AngularJS 도구를 사용하는 방법은 무엇입니까? AngularJS에서 jQuery를 어떻게 사용하나요?

AngularJS 도구를 사용하는 방법은 무엇입니까? AngularJS에서 jQuery를 어떻게 사용하나요?

寻∝梦
寻∝梦원래의
2018-09-08 14:33:241630검색

이 글에서는 주로 angularjs 도구를 사용하는 방법과 Anglejs에서 jQuery를 사용하는 세부 사항을 함께 살펴보겠습니다.

1. Angularjs 도구 메서드

(1)angular.isArray(value)는 배열인지 확인하고 true/false를 반환합니다.

<p>{{isArray}}</p>
$scope.arr=[1,2,3];
$scope.isArray=angular.isArray($scope.arr);

(2)angular.isDate(value)는 배열인지 확인합니다. 날짜 유형을 지정하고 true/false를 반환합니다.

(3)angular.idDefined(value) 정의 여부를 확인하고 true/false를 반환합니다.

(4)angular.isElement(node) DOM 노드인지 확인하고 true/를 반환합니다. false

(5) angle.isFunction(value)은 함수 유형인지 확인하고 true/false를 반환합니다.

(6) angle.isNumber(value)는 NaN, Infinity 및 -Infinity를 포함한 숫자 유형인지 확인합니다. , true/false를 반환합니다.

(7)angular.isObject(value)는 객체 유형인지, Array는 객체 유형인지, Null은 객체 유형이 아닌지 확인하고 true/false를 반환합니다

(8)angular.isString (값)은 문자열 유형인지 확인하고 true/false를 반환합니다

(9)angular.uppercase(값) 대문자로 변환

<p>{{name1}}</p>
 $scope.name='zhangsan';
 $scope.name1=angular.uppercase($scope.name);

(10)angular.lowercase(값) 소문자로 변환

(11)angular .equals(o1,o2) 두 문자열이 같은지 확인하고 true/false를 반환합니다.

<p>{{eq}}</p>
$scope.a='111';
$scope.b='111';
$scope.eq=angular.equals($scope.a,$scope.b);

(12)angular.extend(dst,src) 상속 관계, 다음 코드에 표시된 대로 b는 a

$scope.a={name:'张三'};
$scope.b={age:10};
$scope.c=angular.extend($scope.b,$scope.a);
console.log($scope.b);//{"age":10,"name":"张三"}
의 속성을 상속합니다.

(13)angular.fromJson(json) json 문자열을 역직렬화하고 json 문자열을 JavaScript 객체로 변환합니다.

 var json = '{"name":"hello","age":"20"}';
 console.log(json);
 $scope.json=angular.fromJson(json);
 console.log($scope.json);

AngularJS 도구를 사용하는 방법은 무엇입니까? AngularJS에서 jQuery를 어떻게 사용하나요?

(14)angular.toJson(obj,pretty) json 문자열 형식

 var json = {"name":"hello","age":"20"};
 // console.log(json);
 // $scope.json=angular.toJson(json);
 $scope.json=angular.toJson(json,true);
 console.log($scope.json);

AngularJS 도구를 사용하는 방법은 무엇입니까? AngularJS에서 jQuery를 어떻게 사용하나요?(15)angular .copy( source,[destination]) 다음 코드와 같이 a를 b


에 복사합니다.
              $scope.a={name:'张三'};
              $scope.b={age:10};
              $scope.c=angular.copy($scope.a,$scope.b);
              console.log($scope.a);
              console.log($scope.b);

AngularJS 도구를 사용하는 방법은 무엇입니까? AngularJS에서 jQuery를 어떻게 사용하나요?(16)angular.forEach(obj, iterator, [context]) 

              var json = {"name":"hello","age":"20","sex":'男'};
              angular.forEach(json,function(val,key){
                    //console.log(val);
                  console.log(key);
              });

AngularJS 도구를 사용하는 방법은 무엇입니까? AngularJS에서 jQuery를 어떻게 사용하나요?

              var json = {"name":"hello","age":"20","sex":'男'};
              var results=[];
             angular.forEach(json,function(val,key){
                  //console.log(val);
                  //console.log(key);
                  this.push(key+'--'+val);
              },results);
              console.log(results);

(17)angular.bind(self, fn, args);绑定对象,作为函数的上下文


              var self={name:'张三'};
              var f=angular.bind(self,function(age){
                        $scope.info=this.name+' is '+age;
                        console.log($scope.info);
              });
              f(30);
              var f=angular.bind(self,function(age){
                  $scope.info=this.name+' is '+age;
                 console.log($scope.info);
              },10);
              f();

AngularJS 도구를 사용하는 방법은 무엇입니까? AngularJS에서 jQuery를 어떻게 사용하나요?本篇文章到这就结束了(想看更多就到PHP中文网AngularJS使用手册中学习),有问题的可以在下方留言提问。

위 내용은 AngularJS 도구를 사용하는 방법은 무엇입니까? AngularJS에서 jQuery를 어떻게 사용하나요?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.