Angular.module is not loading in IE 11 - javascript

My application is trying to load the angular module discApp . This is working without any issues in Chrome . But in IE11 i am getting an error like below
object doesn't support property or method 'module' .
Angular Version is using is v1.5.5. If i try ctrl+F5 its loading correctly . Is there any way to fix this issue?
My Js Code where the error throwing in IE is below .
'use strict';
var discApp = angular.module('discApp', ['discApp.controllers']); //Error in this line
Below is the code where i am adding the angular.js
<script>document.write("<script type='text/javascript'
src='js/angular/angular.js?v=" + Date.now() + "'><\/script>");</script>

Please try to modify your code as below, and check whether it meets the same error?
'use strict';
var discApp = angular.module('discApp', []);
If it still meets the same error, perhaps the issue is related to the angular.js reference, try to use the following script to load angular.js reference:
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js"></script>
If the error disappears, the issue is related to the 'discApp.controllers', you could check it.

Related

DOJO Error: defineAlreadyDefined

I am using DOJO and JavaScript. The code is working fine with other browser except Chrome. Whenever I am trying to load the page in Chrome, I am getting following error
{ Error: defineAlreadyDefined
at makeError(dojo.js:119)
at async(dojo.js:1911)
at dojo.js:1941
(anonymous) # dojo.js:1862 }
At line number 119 of dojo.js file I have written following code:-
{ makeError = function(error, info){
return mix(new Error(error), {src:"dojoLoader", info:info}); }
},
At line 1911 I have written following code
{ (this.dojoConfig || this.djConfig || this.require || {}, }
What is the issue ? Can anyone solve this ? I am getting only this issue in chrome.In other browser its working absolutely fine.
Thanks in advance. :-) "
Well, When I faced the same error in my project; below are suggestions I followed to track and fix the error-
The main cause of this error if you are using two different which exposes same "define" method.
However if you are loading same library twice in your application in that case also it gives the same error.
This is the simler error raised on GitHub-
https://github.com/odoe/iLikeItHere/issues/1
Hoping above hint will help to track/resolve your issue :)
The issue could be caused by a external libraries which could use isown define function.
Make sure any external libraries which use their own define like requirejs are always added in header before dojo.
Related answer:
Dojo 1.9 build 'multipleDefine' error while loading locale

Having issues while loading the ExtJS based app with google feeds api

Having issues while loading my app which is based on ExtJS and using Sencha 5.1.3.61. The problem seems to be in this file ext/packages/ux/src/google/Feeds.js.
Getting this error on app launch..
"?file=feeds&v=1.x&output=nocss%3Dtrue&async=2:1 Uncaught Error: Module:'feeds' not found!"
Any solution or work around can be helpful!!
You can try overriding it, like:
Ext.define('Fiddle.ux.google.Feeds', {
override: 'Ext.ux.google.Feeds',
requiresGoogle: {}
});
Issue got resolved by replacing requiresGoogle : {...} with _requiresGoogle : {...}. Thats it.
Source : https://www.sencha.com/forum/showthread.php?334652-Google-Feed-API-deprecated/page2 .

RequireJS and IE9

I've tried to find the solution in previous questions but i couldn't.
I have a web project developed in jquery using requireJS. Everything seems to work fine (in all modern browsers) until i tested in IE9 where there isn't a script working. I tried to find the cause but all i can get is the feedback from dev tool console:
SCRIPT1002: Syntax error libCommon.js, line 10 character 3
SCRIPT445: Object doesn't support this action libEvents.js, line 5
character 2
This is the beginning code of libCommon.js:
//generic JS for all views
define(['jquery'], function ($) {
var LibCommon = function () {};
LibCommon.prototype.hideSubmenu = function() {
$submenu.removeClass('show');
}
LibCommon.prototype.toggleSubmenu = function(tipo) {
const $tipoSubmenu = $('#'+tipo);
this.hideSubmenu();
if (!$tipoSubmenu.hasClass('show')) {
$tipoSubmenu.addClass('show');
} else {
$tipoSubmenu.removeClass('show');
}
};
//and other functions...
And this is the beginning code of libEvents.js:
//generic JS for all views
define(['jquery', 'bootstrap', './libCommon', 'modernizr'], function ($, Bootstrap, LibCommon, Modernizr) {
var common = new LibCommon();
/**
* =================
* TO EXECUTE WHEN INIT
* =================
*/
$( document ).ready(function() {
console.log('initialized all common events');
var common = new LibCommon();
// Fixed header
var stickyNavTop = $('.topmenu').offset().top;
common.fixedNav(stickyNavTop);
$(window).scroll(function() {
common.fixedNav(stickyNavTop);
});
// and other functions or events...
In both errors it's first character of creating a variable/instance of an object after defining all objects/dependencies in requireJS, so it shouldn't be an error. I tried by changing for var common = 0; but error continues appearing in console. It seems that IE9 doesn't like any script. Otherwise, require's instances are working because bootstrap is working properly. Any idea?
Shilly already pointed out in a comment that you should not pass ES6 constructs to IE9. Either write ES5 or use a tool to transpile it.
Now, the error you are getting in libEvents is bizarre because libCommon should not have loaded at all, and consequently the factory of libEvents should not run because one of the dependencies did not load. It is possible to have a module load and later give errors. But I don't recall ever seeing a syntax error in the immediately-interpreted code of a module that did not just cause the load to fail. (The code you are showing is interpreted immediately, even if it is executed later. If you had an eval(string_of_code) in there or a Function(string_of_code) then string_of_code would be interpreted later but this is not something that happens in your code.) I suspect the reason RequireJS goes ahead with executing the factory for libEvents has to do with a problem catching load failures in IE9 and lower. The documentation suggests turning on enforceDefine. I would do this for your code. This won't solve everything but it may help RequireJS detect problems better.
console.log will also probably give you troubles, as explained by this question and answer.

(window.beforeEach || window.setup) is not a function

I've tried to setup a testing environment with mocha, phantomjs and istanbul (and grunt). It works great so far, but when it comes to angular-testing i got some problems. I want (and need) to use angular-mocks, but as soon as I include it in my test.html, I get the following console-error in my browser:
Uncaught TypeError: (window.beforeEach || window.setup) is not a function
The matching code in angular-mocks.js is the following one:
(window.beforeEach || window.setup)(function() {
annotatedFunctions = [];
currentSpec = this;
});
This happens both for the current version (1.4.3) and for an old version which apparently worked in another project: 1.3.15.
What am I missing?
I fixed it.
The problem was, that i included my librarys (including angular-mocks.js) before mocha.js which apparently doesn't work.

Using SnapEngage with Emberjs cause a JS error

As soon as I add:
<script src="/bower_components/ember/ember.min.js"></script>
on the same page where there's our snagengage chat code:
<!-- begin SnapEngage code -->
<script type="text/javascript">
(function() {
var se = document.createElement('script'); se.type = 'text/javascript'; se.async = true;
se.src = '//commondatastorage.googleapis.com/code.snapengage.com/js/4f645e9b-afb9-4226-9ebc-f8fc52d28cef.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(se, s);
})();
</script>
<!-- end SnapEngage code -->
it provokes an error:
Uncaught TypeError: Cannot call method 'push' of undefined 4f645e9b-afb9-4226-9ebc-f8fc52d28cef.js:223
YAHOO.register 4f645e9b-afb9-4226-9ebc-f8fc52d28cef.js:223
(anonymous function) 4f645e9b-afb9-4226-9ebc-f8fc52d28cef.js:242
Anyone ever experienced this? Any suggestion about how to fix this?
PS: I tried removing that JS line and it works, that's definitively a conflict between Ember and some YAHOO library I guess.
Thanks!
I opened a ticket on this with SnapEngage and they recently pushed out a fix. If you had a SnapEngage account prior to Mar 6, 2014, then you need to click "Save" within the "Style" section of your account in order for the JS to be updated to the latest version. After this, the error should go away - worked for me!
NOTE: I am using Ember 1.4.0
I had this same issue and I think it was caused by a _super() on the YAHOO.register function cycling through line 233 twice. The first time it does it the variables k.versions and k.builds are defined, but the second time they are not (perhaps because the super reruns the YAHOO.register function without passing in any arguments. Regardless of exactly what caused it, I was able to remedy the issue (albeit in a VERY hacky way) by making the following edits to the snapengage.js source:
1) On line 233 change:
k.versions.push(p);k.builds.push(q);
to:
k.versions ? k.versions.push(p):false;k.builds ? k.builds.push(q):false;
All this does is check to see if the variables are defined and if they are, push to them. If not, do nothing.
I placed the edited snapengage.js source file in app/assets/javascripts/vendor/ and then added the following line to my application.js file:
//= stub ./vendor/snapengage.js
This will stop your ember application from loading the SnapEngage source when the app loads.
Finally, I wrote a chat mixin and loaded the snapengage.js script as follows:
App.Chat = Em.Mixin.create({
agentOnline: false,
didInsertElement: function() {
this._getChatApi();
},
_getChatApi: function() {
var url = 'assets/home/vendor/snapengage.js',
_this = this;
$.getScript(url).done(function() {
// Your custom SnapEngage Javascript API code here. For example...
SnapEngage.getAgentStatusAsync(function(online) {
_this.set('agentOnline', online);
});
});
},
});
App.IndexView = Em.View.extend(Home.Chat, {
// The rest of your view code here
});
The snapengage.js script won't load itself twice but if you're using the mixin on multiple pages you might want to make sure you're not loading the chat assets (images, loading spinner, etc) twice because the plugin seems to make a call to snapengage.com everytime you click on the 'help' button rendered on the webpage.
As I mentioned, it's a very hacky solution and I don't recommend editing the source code for plugins, but this will give you a fix to easily use Snapengage in an Ember.js app.

Categories