Search code examples
javascriptangularjsangularjs-material

Angularjs Material $mdDialog Controller Not Working On Specific Computers


I've got mdDialog as shown below

function selectAddress(addressType) {
  $mdDialog.show({
    controller: function ($scope, $mdDialog) {
      var savm = $scope;
      savm.addressType = addressType;
      savm.close = $mdDialog.hide;

      savm.foo = function () {

      };

      savm.bar = function () {

      };
    },
    template: require('../views/dialog/address-select.template.view.html'),
    parent: angular.element($window.document.body),
    clickOutsideToClose: true,
  });
}

This code working on two mac in office, but not working on other os (Ubuntu and Windows) and it gives this error:

angular.js:14940 TypeError: invokeCtrl is not a function
   at MdCompilerService.MdCompilerProvider.MdCompilerService._createController (angular-material.js:2729)
   at Object.linkFn [as link] (angular-material.js:2689)
   at linkElement (angular-material.js:4375)
   at angular-material.js:4251
   at processQueue (angular.js:17318)
   at angular.js:17366
   at Scope.$digest (angular.js:18479)
   at Scope.$apply (angular.js:18867)
   at HTMLButtonElement.<anonymous> (angular.js:28028)
   at defaultHandlerWrapper (angular.js:3795)

All package versions are equal in these computers:

angularjs: 1.7.0,

angularMaterial: 1.1.9,

chrome: Version 67.0.3396.99 (Official Build) (64-bit)

What is the solution to this problem.

PS: Do not stick to the 'require'. We use WebPack.


Solution

  • As @mvermand says, This is a bug in angularjs which is solved in 1.7.2. Upgrade your angularjs.