저는 angularjs에서 매우 새로 왔습니다.텍스트 상자에서 키를 누르면 컨트롤러 메서드를 호출하는 방법?
anglejs의 텍스트 상자에 텍스트를 입력 할 때 ajax 호출을 사용하여 컨트롤러 메서드를 호출하고 싶습니다.
텍스트 상자의 키 누르기에서 내 컨트롤러 메서드를 호출하거나 제거하려고합니다.
$http.get('../Home/GetFriendsList').success(function (data) {
$scope.friends = data;
})
.error(function() {
$scope.error = "An Error has occured while loading posts!";
});
이 사람이 나를 도울 수
??? : 내가 해고하려면이 텍스트 상자에 아무 키나 눌러에<input type="text" data-ng-model="newfriend.SearchText" required />
이 전화 텍스트 상자에 업데이트 된 값으로 MyMethod라는 함수를 호출하는
<input type="text" data-ng-model="newfriend.SearchText" ng-change="myMethod()" required />
$scope.myMethod = function() {
$http.get('../Home/GetFriendsList').success(function (data) {
$scope.friends = data;
})
.error(function() {
$scope.error = "An Error has occurred while loading posts!";
});
}
또 다른 방법 :
$watch()
코드 ... – MadhuNG-키를 누를 때 지침이 거기에 제발 제공 사용할 때, MyMethod라는 함수를 호출합니다. – Ved