Matoy Matoy - 3 months ago 16
AngularJS Question

angular's error message " Failed to instantiate module" only in explorer

I am trying to create a chat application with angular on the front end.

I added a new function called isUserTyping to the controler of the chat and tested in on chrome. it worked fine.

in explorer however the page does not load with that function (once I remove it it works fine).
Ther error I get in the consoelo is this:

"SCRIPT5022: [$injector:modulerr] Failed to instantiate module mymodule due to: Error: [$injector:nomod] Module 'mymodule' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument."

I don't know what this error means.... I attached below the code I have.

If someone has any idea to what causes this in explorer I will greatly appraicate it.

script js:

var mymodule = angular.module('mymodule', ['ngRoute']);
mymodule.config(function($routeProvider) {
.when('/', {
templateUrl : 'pages/enter.html',
controller : 'SharedController'
.when('/chat', {
templateUrl : 'pages/chat.html',
controller : 'cntrlChat'

mymodule.factory('myService', function() {
var savedData = {}
var set=function (data) {
savedData = data;
function get() {
return savedData;

return {
set: set,
get: get


mymodule.controller('SharedController', ['$scope', 'myService','$location',
function($scope, myService, $location){

$scope.updateMsg = function (msg) {

$scope.getMsg = function () {
$scope.message = myService.get();


mymodule.controller("cntrlChat", ['$scope', 'myService','$q','$timeout',
function($scope, myService,$q,$timeout){
var socket = io();
$scope.messages = [];
$ myService.get();
socket.emit('room', $;

socket.emit('chat_message',{ room: $, msg: $": "+$scope.insertedText });
return false;

socket.on('chat_message', function(msg){
$scope.$apply(function() {


socket.on('info_message', function(msg){
$scope.$apply(function() {


$scope.isUserTyping= function() {
var runTwoFunctionWithSleepBetweenThem=function(foo1, foo2, time) {
$q.when(foo1()).then(() => $timeout(foo2, time));
runTwoFunctionWithSleepBetweenThem(function (){socket.emit('info_message', { room: $, msg: 'user is typing...' })},
function (){socket.emit('info_message', { room: $, msg: '' });},1500);



*<form ng-submit="submit()">
<input autocomplete="off" ng-model="insertedText" ng-change="isUserTyping()" type="text" />
<button type="button" ng-click="submit()">


you are using lambda expression function, this syntax is ECMA6 syntax, which is not supported at any type of IE....

you should use function expression instead:

  var runTwoFunctionWithSleepBetweenThem=function(foo1, foo2, time) {
   $q.when(foo1()).then(function() {
     $timeout(foo2, time);