Я пытаюсь написать приложение angularjs, когда я запускаю код, я получаю сообщение об ошибке:
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module ui.grid due to:
Error: [$injector:nomod] Module 'ui.grid' is not available! You either misspelled the module name or
forgot to load it. If registering a module ensure that you specify the dependencies as the second
argument.
Файл Index.cs html:
@{
ViewBag.Title = "Index";
}
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="~/scripts/ui-grid.js"></script> <- This is the reference that throw the error
<link href="~/Content/ui-grid.css" rel="stylesheet" />
<script src="~/scripts/fileUpload.js"></script> <- This is my angularjs application
<style>
.uiGrd {
width: 550px;
height: 300px;
}
</style>
</head>
<body>
<div ng-app="myApp"
ng-controller="myController">
<input type="file" id="file1" name="file" ng-files="getTheFiles($files)" />
<input type="button" ng-click="uploadFiles()" value="Upload" />
<div class="uiGrd" id="grd" ui-grid="gridData"></div>
</div>
</body>
</html>
Файл Загрузить. js
var app = angular.module('myApp', ['ui.grid']);
app.directive('ngFiles', ['$parse', function ($parse) {
function fn_link(scope, element, attrs) {
var onChange = $parse(attrs.ngFiles);
element.on('change', function (event) {
onChange(scope, { $files: event.target.files });
});
};
return {
link: fn_link
}
}]);
app.controller('myController', function ($scope, $http) {
var formdata = new FormData();
$scope.getTheFiles = function ($files) {
angular.forEach($files, function (value, key) {
formdata.append(key, value);
});
};
// SEND FILES TO THE API USING POST METHOD.
$scope.uploadFiles = function () {
var request = {
method: 'POST',
url: '/api/fileupload/',
data: formdata,
headers: {
'Content-Type': 'application/json'
},
transformRequest: angular.identity
};
$scope.arr = new Array;
// SEND THE FILES.
$http(request)
.success(function (data) {
var i = 0;
// LOOP THROUGH DATA.
angular.forEach(data, function () {
var b = {
Name: data[i].Name,
Email: data[i].Email
};
$scope.arr.push(b); // ADD DATA TO THE ARRAY.
i += 1;
});
})
.error(function () { });
}
$scope.gridData = { data: 'arr' }; // BIND ARRAY (WITH DATA) TO THE GRID.
});
Я застрял с этой ошибкой. Это проблема с орфографической ошибкой? Я неправильно делаю инъекцию? Ошибка возникает сразу же при открытии страницы, поэтому я не могу получить доступ к какой-либо функции, поскольку эта ошибка приводит к нарушению всего кода.
Может кто-нибудь предложить помощь?
Спасибо , Эразмо