MD Ghouse MD Ghouse - 1 month ago 12
AngularJS Question

Uncaught Error: [$injector:modulerr]

Here im trying to use Autocomplete textbox using angularJs when im loading my view its throughing an error as "Uncaught Error: [$injector:modulerr] "

**Html Code*

<div ng-controller="ngAutoCompleteController">
<div angucomplete-alt id="txtAutocomplete" placeholder="Type country name" pause="100"
selected-object="afterSelectedCountry" local-data="Employees" search-fields="Name"
title-field="Name" minlength="1" input-class="form-control" match-class="highlight">

</div>

<div ng-show="SelectedCountry">
Selected Country : {{SelectedCountry.Employees}}
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.2/angular.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular-resource.min.js"></script>
<link href="~/Content/angucomplete-alt.css" rel="stylesheet" />
<style type="text/css">
.angucomplete-dropdown {
overflow-y: auto;
max-height: 200px;
}
</style>


Angular.Js

var app = angular.module('myApp', ['angucomplete-alt']);
app.controller('ngAutoCompleteController', ['$scope', '$http', function ($scope, $http) {
$scope.Employees = [];
$scope.SelectedCountry = null;


//After select country event
$scope.afterSelectedCountry = function (selected) {
alert('Enter in Control autocom')

if (selected) {
$scope.SelectedCountry = selected.originalObject;
}
}

//Populate data from database
$http({
method: 'GET',
url: '/home/GetCountries'
}).then(function (data) {
$scope.Employees = data.data;}]);


mvc controller

public JsonResult GetCountries(){
var x =( from n in db.Employees orderby n.Name select n).ToList();return new JsonResult { Data = x, JsonRequestBehavior = JsonRequestBehavior.AllowGet };}

Answer

You need to refer the corresponding angucomplete-alt.js in the view,

<script src="https://github.com/ghiden/angucomplete-alt/blob/master/angucomplete-alt.js"></script>