각도의 선행을 사용하고 있으며 ngModel에 문제가 있습니다. 때 여기 ng-model이 선행 기입으로 작동하지 않습니다.
여기 내 선행 입력 html로<input
type= "text"
ng-model= "symbol"
placeholder= "begin typing"
typeahead= "hit.message for hit in getTypeAheadContents($viewValue)"
typeahead-loading= "loadingSymbols"
typeahead-editable= "false"
typeahead-on-select= "onSelect($item, $model, $label)"
typeahead-min-length= 2
typeahead-wait-ms= 500
class= "form-control"
/>
<input ng-click= "search()" value= "Search!"/>
입니다 예상대로
$scope.search = function(){
alert($scope.symbol);
}
이제 자동 완성 코드가 작동 내 컨트롤러의 코드 (시간 인을위한 아주 기본)이지만, 검색 버튼을 클릭하면 "undefined"라는 경고 메시지가 나타납니다.
설정을 시도한 것이 더 이상합니다.
$scope.symbol = "";
내 컨트롤러 시작 부분에 아무 것도 입력하지 않고 검색 버튼을 클릭하면 예상대로 빈 문자열이 나에게 다시 알립니다. 그러나 타입 어 헤드에 무언가를 입력하고 다시 검색을하면 "undefined"가 다시 나타납니다. 그래서 명확하게, 각도의 형형색색은 모델과 매우 잘 놀지 않고 있지만, 여기서 무엇을해야할지 모르겠습니다.
조언?
:-)
typeahead-editable="true"
을 설정 (깊은 $ 시계 될 수있다), 그러나 나에게 돌아와 주셔서 감사합니다 . 감사합니다. – Zack