2017-02-23 3 views
0

난 그 HTML 부분으로 정의된다 따르는 각 성분을 가지고NG 변화 일으키는 각도 오차

<div ng-class="{'chiptag2': !$ctrl.tag.isNew, 'chiptag-placeholder': $ctrl.tag.isNew, 'highlighted-tag': $ctrl.tag.isSelected}" 
     ng-change="$ctrl.onChipChange($ctrl.tag)" 
     ng-focus="$ctrl.onChipFocus($ctrl.tag)" 
     ng-blur="$ctrl.onChipBlur($ctrl.tag)" 
     contenteditable> 
{{$ctrl.tag.title}} 
</div> 

제어기 다음 미리 가지고

this.onChipFocus = function(tag){ 

    console.log('editableChipComponent onChipFocus for new tag'); 

}; 

this.onChipChange = function(tag){ 

    console.log('editableChipComponent onChipChange has '+tag.title); 

}; 

this.onChipBlur = function(tag){ 

    console.log('editableChipComponent onChipBlur for '+tag.title); 

}; 

성분을

<editable-chip-component 
     ng-repeat="tag in tagcategory.tags" 
     tag="tag" 
     bluemoon="$ctrl.toggleTagSelection(tag)" 
></editable-chip-component> 

내가 포함하지 않으면 모든 것이 잘 작동합니다. 구성 요소 html 부분의 ng-change 특성 그러나 최대한 빨리 다음 NG 반복 나누기 첫 번째 항목을 추가 한 후 NG-변화를 추가하고, 콘솔은 다음과 같은 오류 같이 :

Error: [$compile:ctreq] http://errors.angularjs.org/1.6.1/$compile/ctreq?p0=ngModel&p1=ngChange 
    at angular.js:38 
    at V (angular.js:9722) 
    at n (angular.js:9645) 
    at g (angular.js:8881) 
    at n (angular.js:9635) 
    at angular.js:9980 
    at angular.js:16648 
    at m.$eval (angular.js:17972) 
    at m.$digest (angular.js:17786) 
    at m.$apply (angular.js:18080) 

사람이에 어떤 빛을 창고 수를? ng-repeat에서 변경을 할 수 있어야합니다. 맞습니까?

감사합니다. ng-change를 사용하는 ng-model .. 즉, 요구되는 당신이 ng-model 강제를 사용해야합니다

+0

'ng-change'는 바인드 된 변수 ('ng-model')가 필요합니다. 당신은 div에서 그것을 사용할 수 없습니다. – Mistalis

답변

0

당신은 사업부에 ng-change를 사용하지 못할는 등 체크 박스, 라디오, 텍스트와 같은 입력 요소에만 적용됩니다.

귀하의 경우에는 ng-click을 사용하십시오.

ng-change의 경우 Docs입니다.

+0

감사 Saurabh, 많이 감사하겠습니다. – Journeyman