I am a beginner in Angular JS and encountered an issue while trying to load a JS file in a cshtml extension. I was able to alert the message 'testing 1' but not 'testing 2'. Can someone help me understand what might be causing this issue? Any guidance would be greatly appreciated. My understanding is that when the page loads, it should run the $q.all function correctly. However, for some reason, it's not functioning as expected.
var app = angular.module('myApp');
alert("Testing 1");
app.controller('ListController', function ($scope, $q, $http,$timeout) {
function doTask1() {
var deferred = $q.defer();
deferred.resolve("Testing 2");
return deferred.promise;
}
console.log("ListController instantiated");
$q.all([
doTask1(),
]).then(function (value) {
alert(value);
});
});
Within the cshtml file (all Angular dependencies are located in "~/Views/Shared/_Layout.cshtml"), there are no errors in the console log indicating that Angular has been successfully imported.
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div ng-controller="ListController as listCtrl" class="margin-top-80px">
</div>
@section Scripts{
<script src="~/Scripts/controllers/News/ListController.js"></script>
}