7
我已經使用了風格的一個從這裏:http://tympanus.net/Development/TextInputEffects/index.html角浮動輸入標籤預讀取
創建一個輸入指令,請參閱plunker:https://plnkr.co/edit/wELJGgUUoiykcp402u1G?p=preview
這偉大的工作標準輸入字段,但是,我正在努力工作Wirth Twitter typeahead:https://github.com/twitter/typeahead.js/
問題 - 我怎樣才能使用我的浮動輸入標籤與typeahead?
app.directive('floatInput', function($compile) {
return {
restrict: 'E',
replace: true,
transclude: true,
scope: {
elemTitle: '=elemTitle',
elemtId: '=elemeId'
},
templateUrl: 'input-template.html',
link: function(scope, elem, attrs) {
var ngModelName = elem.attr('input-model');
var inputElem = angular.element(elem[0].querySelector('input'));
inputElem.attr('ng-model', ngModelName);
$compile(inputElem)(scope);
$compile(inputElem)(scope.$parent);
var inputLabel = angular.element(elem[0].querySelector('label span'));
inputLabel.attr('ng-class', '{\'annimate-input\' : '+ngModelName+'.length > 0}');
$compile(inputLabel)(scope);
},
controller: function($scope) {
$scope.title = $scope.elemTitle;
$scope.inputId = $scope.elemId
}
}
})
HTML:
<div>
<span class="input input--juro">
<input class="input__field input__field--juro" type="text" id="{{inputId}}" ng-model="tmp" />
<label class="input__label input__label--juro" for="{{inputId}}">
<span class="input__label-content input__label-content--juro">{{title}}</span>
</label>
</span>
</div>
你去哪裏引用代碼中的'typeahead'? –
@JossefHarush - 我還沒有,我不知道從哪裏開始。 –
請更清楚您的問題。你有什麼嘗試?你看到一個錯誤? –