2017-09-14 3 views
1

lade Ich versuche, eine der automatische Vervollständigung Textbox mit AngularJS zu tun, habe ich ngAutocomplete in Winkelmodul hinzugefügt, aber nicht in der Lage, die Richtlinie

Angular-Code zu laden:

"use strict"; 
var app = angular.module('npi', ['ngRoute', 'ngSanitize', 'ngFileUpload', 'ngAutocomplete','ui.bootstrap']); 

app.config(['$compileProvider', '$routeProvider',function($compileProvider, $routeProvider) { 
    $compileProvider.commentDirectivesEnabled(false); 
    //$compileProvider.cssClassDirectivesEnabled(false); 
    //$compileProvider.debugInfoEnabled(false); 
    $routeProvider 
     when("/part/:part_id", { 
      templateUrl : "/html/part_detail.html", 
     controller : "partDetail" 
     }) 
    }]); 

part_details.js

"use strict"; 
app.controller("partDetail", [ 
     '$scope', 
     '$http', 
     '$log', 
     '$window', 
     '$routeParams', 
     function($scope, $http, $log, $window, $routeParams) { 
      $scope.$parent.title = "Part Detail"; 
      $scope.$parent.selectpartAttribute = ""; 
      $scope.sample = ['one','two','three','four','five','six']; 
      } ]); 

part_detail.html

<input auto-complete ui-items="sample" ng-model="selectpartAttribute.attribute_group" /> 
<input type="text" ng-model="selectpartAttribute.attribute_name" /> 
<input type="text" ng-model="selectpartAttribute.attribute_value" /> 

auto_complete.js

"use strict"; 
app.directive('autoComplete', function($timeout) { 
    return function(scope, iElement, iAttrs) { 
    iElement.autocomplete({ 
     source: scope[iAttrs.uiItems], 
     select: function() { 
     $timeout(function() { 
      iElement.trigger('input'); 
     }, 0); 
     } 
    }); 
    }; 
}); 

Nun Richtlinie nicht geladen, wenn input

Fehler enter image description here Vielen Dank im Voraus

+3

Stellen Sie sicher, dass Sie 'ngAutocomplete.js' (oder die Datei, die dieses Modul enthält) in Ihren '

Verwandte Themen