I am new in AngularJS. I want to take a text with autocomplete. In that autocomplete, my JSON is retrieved from JS. I don't have an idea to simplify. Give me a simple idea.
Requirement is autocomplete textbox orderBy name using custom directives link and compilation.
angular.module('docsSimpleDirective', []).controller('Controller', ['$scope', function($scope) {
$scope.customer = [{name: 'Samudrala',address: '500033 Warangal'},
{name: 'Raamu',address: '500088 Karimnagar'},
{name: 'Namini',address: '500044 Kukatpalli'}
];
}]).directive('myCustomer', function() {
return {
Restrict: 'E',
template: '<input type="text"/><ul ng-repeat ="cust in customer||filter"><li>{{"Name : "+cust.name+" - And - "+" Address : "+cust.address}}</li></ul>'
};
});
li{
list-style-type: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="docsSimpleDirective" ng-controller="Controller">
<div my-customer></div>
</div>