0
각도로 필터를 생성하는 경우 tutorial을 통해 작업하고 있습니다. 나는 구현의 일부와 혼동스러워하고 근본적인 자바 스크립트 내려 온다. 대구 스 니펫은 다음과 같습니다.사용자 정의 필터 구문
// on the app object, the method filter is called passing a name parameter and the function
myApp.filter('reverse', function() {
return function (text) {
// now a function that accepts text as a parameter is returned
return text.split("").reverse().join("");
// the text parameter splits, revers, and joins the text parameter.
}
});
제 질문은 왜 이런 식으로 작성할 수 없습니까? 두 번째 줄의 첫 번째 스 니펫에서 함수를 반환하는 목적은 무엇입니까?
myApp.filter('reverse', function (text) {
return text.split("").reverse().join("");
});
'filter'로 전달하는 함수가 종속성 삽입 가능하므로. – elclanrs