0
검색 기능을 사용하여 드롭 다운을 생성하라는 지시문을 만들었습니다. 이 지시어에서는 'searchSearchBtn'이라는 플래그를 사용했습니다.이 플래그는이 버튼을 표시하고 있습니다.
좋아,
, 나에게 명확한 아이디어, 내 코드를 보여주지 각도 지침
angObj.directive('largeListSearch', function(domainReports){
return {
restrict: 'AE',
scope:{
selectedObj:"=",
listColumns: "=",
showSearchBtn:"="
},
template: '...'+
'<input style="width: 350px;" class="dropdown-toggle inactive dd_txt" ng-model="selectedObj.name" id="campaignDropdown" title="{{selectedObj.name}}" placeholder="{{selectedObj.name }}" />'+
'<input type="button" value="Search" id="element" style="display: none" data-ng-click="filterDropDown()" />'+
'...',
link: function ($scope, element, attrs) {
$scope.filter = function(val) = {
//Logic to filter the campaigns
}
$scope.originalCampaingList = $scope.$parent.campaigns;
//Check the status and load the function accordingly for the campaigns list
if(attrs.showSearchBtn === "true") {
$scope.filterDropDown = function(){
//Function to filter the searched campaign
$scope.filter(val);
};
}else{
$scope.$watch('selectedObj.name', function(oldValue, newValue){
console.log(oldValue + " "+ newValue);
if(oldValue === newValue) {
return;
}
//Function to filter the searched campaign
$scope.filter(val); /HERE Could not able to call the filter function, Is it that, we can not call a function inside $scope.$watch
}
});
}
}
}
});
내 문제 :.은 $ 범위 내에서 함수를 호출 할 수 없습니다 $ 시청
친애하는 친구, 그건 오타입니다.하지만 내 진짜 문제는 매개 변수를 전달하거나하지 않는 함수가 호출되지 않는다는 것입니다. –
이 경우, 나는 그 문제가 무엇인지 정말로 모른다. 직접 코드를 테스트 할 수 있도록 코드를 더 제공 할 수 있습니까? (예 : jsfiddle이 도움이 될 것입니다) – jasonhansel