ng-change 이벤트를 시작하는 태그를 얻으려고하는데 아무 소용이 없습니다. 목적은 post.content의 변경 사항을 보는 것입니다. 코드는 매우 간단하고 간결함을 위해 일부는 생략되었지만 기본적으로 다음과 같이 반복되는 ng 템플릿입니다.
<li ng-repeat="post in posts" data-id="[[post.id]]" data-rank="[[post.sortrank]]" class="post">
<ng-include src="post.template"></ng-include>
</li>
반복되는 템플릿 :
<script type="text/ng-template" id="postText.html">
<pre ng-blur="savePost($event, post)" ng-change="changePost()" ng-model="post.content" class="postText" contenteditable="true">[[post.content]]</pre>
</script>
JS :
$scope.savePost = function($event, post) { //This fires correctly
console.log($event);
console.log(post);
};
$scope.changePost = function() { //This doesn't fire at all
console.log("changed!");
};
contenteditable 속성 때문일 수 있습니까? Angular 튜토리얼 사이트에서 작업하는 ngChange 예제를 얻을 수 있기 때문입니다.
akatov의 angular-contenteditable.js를 사용할 수 있습니다 .
문서에서 ... JS :
angular.module('myapp', ['contenteditable'])
.controller('Ctrl', ['$scope', function($scope) {
$scope.model="<i>interesting</i> stuff"
}])
HTML :
<div ng-controller="Ctrl">
<span contenteditable="true"
ng-model="model"
strip-br="true"
select-non-editable="true">
</span>
</div>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다