I have this simple angular app using angular 1.6.1.
index.html
<!DOCTYPE html>
<html ng-app="App">
<head>
<title>Test</title>
<script src="bower_components/angular/angular.js"></script>
<script src="app/app.js"></script>
</head>
<body>
<div>
<home></home>
</div>
</body>
</html>
app.js
(function() {
'use strict';
var app = angular.module('App', []);
app.component('home', {
template: '<h1>{{$ctrl.head}}</h1><ul><li>1</li><li>2</li></ul>',
controller: function() {
var vm = this;
this.head = "ONE";
}
});
})();
This will load OK and display corretly in IE11, but fails to load on Chrome( 55.0.2883.87 beta (64-bit) or FF (51.0b13 (32-bit) and I have absolutly no idea why ....
whne I click on the app.js in Sources tab in Chrom Dev Tool the source is in wierd chineese like characters, but looking at source via Notepad++, all looks OK ... ?!?!
here is a screenshot of devconsole on chrome
I can see the same issue for every JS file I add to index.html. I didn't change any locale settings aor anything else in the browsers ot my PC ...
I have no idea why is this happening. Anyone seen anything like this?
I had exactly the same problem. In my case, the main HTML page was in localhost and it was calling external .js files out of my control. The problem was present in modern versions of Chrome and Firefox (but not in Internet Explorer). I discovered that the HTML page had been accidentally created in Unicode, instead of UTF8 or ANSI. I used notepad.exe to save it as ANSI (since it was only in English) and that solved the problem.
all files were created in command line by typing
echo "" >> app.js
and this has set encoding to UCS-2 LE BOM
as displayed in Notepad++, and for some unknow reason Chrome and firefox could not read the files correctly ...
So converting file to UTF-8-BOM
in Notepad++ (Menu -> Encoding -> Convert to UTF-8-BOM) file was read fine and all worked...
I would be still interested on why old IE managed to read the site OK, but more modern browsers failed ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With