1

I've have two file that are basically the same. A classic .asp file, and the viewsource of the .asp saved as a HTML file. In both I include the jquery framework, the angular.js framework, and project specific js. The html and asp both contain

<html ng-app="WillisPrecastProjects">

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>

<script src="js/angular.min.js"></script>
<script src="js/precast.js"></script>

<div ng-controller="MainController">
    <div ng-repeat="data in projectData">
        <h3>{{data.name}}</h3>
        <p>{{data.address}}</p>
    </div>
</div>

precast.js:

var app = angular.module('WillisPrecastProjects', []);

// Load JSON
app.controller('MainController', function($scope, $http){
$http.get('js/generic.json').success(function(project_data){
    $scope.projectData = project_data;
});
})

generic.json:

[
{
  "longitude": 19.069341,
  "latitude": -155.566242,
  "heading": 120,
  "name":"Hawaii",
  "address":"Naalehu, HI (USA)",
  "pitch": 10,
  "fov": 90
},
{
  "longitude": 51.876072,
  "latitude": 0.55454,
  "heading": 90,
  "name": "Braintree",
  "address": "Station Approach, BRAINTREE CM7 3QL (UK)",
  "pitch": 10,
  "fov": 90
},
{
  "longitude": 51.794423,
  "latitude": 0.632222,
  "heading": 262.62,
  "name": "Witham, Chipping Hill",
  "address": "Windsor Close, Hatfield Road, WITHAM, CM8 1GH (UK)",
  "pitch": 10,
  "fov": 90
}
]

The Angular works in the html, but does not work in classic asp. Is there a reason why this happens?

Note: I'm viewing the html files through apache localhost via XAMPP. I'm viewing the classic asp in debug mode via IIS in Visual Studio 2013.


1 @Anthony - precisely. No errors are thrown. Angular simply does not work in the VS build of the classic ASP site.

2 @John - The JS pathing is fine. Clicking on the link to each JS file in each view source loads all of the JS files load.

3 @Brian, 4 @John - I'm thinking it might be the way Visual Studio builds. I'm not actually using IIS natively. I'm using Visual Studio's builtin dev server. But what I find interesting is it DOES support classic asp in that I can build the classic asp project/solution that page works. It's just the Angular stuff doesn't work. Perhaps VS's builtin dev server is doing something to the angular tag attributes. But if this was the case how would people CS and ASP.NET programmers build Angular apps in Visual Studio 2013?

I appreciate all your advice and suggestions. My apologies that I cannot supply the actual source code in its entirety. Any other suggestions is greatly appreciated.

Kxmode
  • 251
  • 1
  • 5
  • 11
  • The html and asp files are sitting right next to each other in the same directory and they are 100% identical in View Source? That's bizarre. Any errors in the JavaScript console? – Anthony Chu Apr 14 '14 at 04:07
  • 1
    All your references to JS files are relative. Maybe try absolute references, so instead of "js/..." use "/js/...". See if that helps. Also, check for any JavaScript or resource errors in Developer Tools. – johna Apr 14 '14 at 04:17
  • Yes, they *can* work together, but there's probably a good 10 or 15 things you could be doing wrong that we can't see here. First and foremost, your asp templates are processed by the server, and the IIS is likely tripping on your angular expressions inside your binding brackets. ASP also creates it's own xml namespace, and might be stripping any of your angular xml tags or attributes when it compiles (remember asp will compile before angular). Without seeing your complete architecture and output, there's no telling where the problem is. check error logs on client and server and go from there – Brian Vanderbusch Apr 14 '14 at 04:28
  • Are you actually using IIS, or are you using the inbuilt Visual Studio dev server which supports asp.net but not classic asp? – John Apr 14 '14 at 20:33
  • Can you view the plain html version on IIS through Visual Studio 2013? It could be a missing mime type for static json files: http://stackoverflow.com/questions/19516829/allow-loading-of-json-files-in-visual-studio-express-2013-for-web – Walter May 02 '14 at 17:00
  • Yes, agreed that they can work together. For strategies on how you could migrate an ASP application to using AngularJS, see [this post](http://unstoppablesoftware.com/gradually-upgrading-classic-asp-system-angularjs/). – YeahStu Feb 24 '15 at 03:15

0 Answers0