2017-05-11 4 views
0

각도 응용 프로그램에 에이스 편집기를 구현하는 데 ui-ace 지시문을 사용하고 있습니다. 에이스 편집기에 데이터를 동적으로 추가하는 데 사용하는 버튼이 있습니다. 사용자가 버튼을 클릭하면 setValue 메소드를 사용하여 에이스 편집기의 값을 업데이트하지만 값은 ngModel에 반영되지 않습니다. 그렇게하는 가장 좋은 방법은 무엇입니까? 여기setValue를 사용하여 UI 에이스 에디터의 값을 업데이트 할 때 ngModel을 업데이트하는 방법은 무엇입니까?

내가 만든 값 ...

$scope.addUserInput = function (input) { 
    var currentValue = $scope.aceEditor.getValue(); 

    if(SqlTokenizer.isIdentifier(input.name)){ 
     $scope.aceEditor.setValue(currentValue + ":" + input.name, false); 
    } else{ 
     $scope.aceEditor.setValue(currentValue + ':"'+ input.name +'"', false); 
    } 
}; 

을 설정 plunkr 방법은 여기 http://plnkr.co/edit/ez0cwr6PWhALpqu3wjZT?p=preview

답변

0

업데이트 plnkr 같은 경우 : http://plnkr.co/edit/GCnDPQnC7xoC6xqdOeqd

문제는 UR이 추가됩니다/갱신 편집자의 텍스트는 그렇게 할 필요가 없습니다.

범위 변수를 업데이트하면 모든 바인딩 위치에 반영됩니다. 대신

//$scope.editor.setValue($scope.editor.getValue() + new Date().getTime()); 

$scope.text = $scope.text + new Date().getTime(); 
수행