I'm trying to create a simple KendoUI + AngularJS project. When I use the code below, everything works fine:
<!DOCTYPE html>
<head>
<title>AngularJS</title>
<meta charset="utf-8">
<link href="Content/kendo/2014.2.716/kendo.common.min.css" rel="stylesheet" />
<link href="Content/kendo/2014.2.716/kendo.rtl.min.css" rel="stylesheet" />
<link href="Content/kendo/2014.2.716/kendo.default.min.css" rel="stylesheet" />
<script src="Scripts/kendo/2014.2.716/jquery.min.js"></script>
<script src="Scripts/kendo/2014.2.716/angular.min.js"></script>
<script src="Scripts/kendo.all.min.js"></script>
</head>
<body>
<a class="offline-button" href="../index.html">Back</a>
<div id="example" ng-app="KendoDemos">
<div class="demo-section k-content" ng-controller="MyCtrl">
<div class="box-col">
<h4>Set Value</h4>
<p>
<input kendo-numeric-text-box k-min="0" k-max="100" k-ng-model="value" />
</p>
</div>
<div class="box-col">
<h4>Set Value</h4>
<div kendo-slider k-min="0" k-max="100" k-ng-model="value"></div>
</div>
<div class="box-col">
<h4>Result</h4>
Value: {{value}}
</div>
</div>
</div>
<script>
angular.module("KendoDemos", ["kendo.directives"]);
function MyCtrl($scope) {
$scope.value = 50;
}
</script>
</body>
</html>
But when I try to split the AngularJS code into a separate .js
file (as shown at the end), the page stops working (relative to kendoUI):
<!DOCTYPE html>
<head>
<title>AngularJS</title>
<meta charset="utf-8">
<link href="Content/kendo/2014.2.716/kendo.common.min.css" rel="stylesheet" />
<link href="Content/kendo/2014.2.716/kendo.rtl.min.css" rel="stylesheet" />
<link href="Content/kendo/2014.2.716/kendo.default.min.css" rel="stylesheet" />
<script src="Scripts/kendo/2014.2.716/jquery.min.js"></script>
<script src="Scripts/kendo/2014.2.716/angular.min.js"></script>
<script src="Scripts/kendo.all.min.js"></script>
<script src="Scripts/app/itensApp.js"></script> <!--ADDED-->
</head>
<body>
<a class="offline-button" href="../index.html">Back</a>
<div id="example" ng-app="KendoDemos">
<div class="demo-section k-content" ng-controller="MyCtrl">
<div class="box-col">
<h4>Set Value</h4>
<p>
<input kendo-numeric-text-box k-min="0" k-max="100" k-ng-model="value" />
</p>
</div>
<div class="box-col">
<h4>Set Value</h4>
<div kendo-slider k-min="0" k-max="100" k-ng-model="value"></div>
</div>
<div class="box-col">
<h4>Result</h4>
Value: {{value}}
</div>
</div>
</div>
</body>
</html>
Scripts / itemsApp.js
(function() {
var itensApp = angular.module('KendoDemos', ["kendo.directives"]);
}());
Console:
Error: [ng:areq] http://errors.angularjs.org/1.2.16/ng/areq?p0=MyCtrl&p1=not%20a%20function%2C%20got%20undefined
at Error (native)
at http://localhost:10642/scripts/kendo/2014.2.716/angular.min.js:6:450
at xb (http://localhost:10642/scripts/kendo/2014.2.716/angular.min.js:18:360)
at Ra (http://localhost:10642/scripts/kendo/2014.2.716/angular.min.js:18:447)
at http://localhost:10642/scripts/kendo/2014.2.716/angular.min.js:66:96
at http://localhost:10642/scripts/kendo/2014.2.716/angular.min.js:53:14
at q (http://localhost:10642/scripts/kendo/2014.2.716/angular.min.js:7:386)
at J (http://localhost:10642/scripts/kendo/2014.2.716/angular.min.js:52:382)
at f (http://localhost:10642/scripts/kendo/2014.2.716/angular.min.js:46:399)
at f (http://localhost:10642/scripts/kendo/2014.2.716/angular.min.js:46:416) angular.min.js:89
GET http://localhost:10642/scripts/kendo/2014.2.716/angular.min.js.map 404 (Not Found)
What am I doing wrong?