AngularJS $广播在IE / Edge浏览器中无法正常工作

时间:2016-11-30 21:07:17

标签: javascript angularjs

我有以下代码由于某种原因在IE / Edge中无法正常工作。我使用的是AngularJS 1.5.0版。

在我的服务someservice.js中,我有以下代码:

   // Codes to do something here before broadcasting changes
   $rootScope.$broadcast("updateMade");

在我的控制器中,我的代码看起来像这样:

angular.module(‘app’).controller(“someCtrl”, function($scope, $stateParams, someservice) {

var vm = this;
vm.id = $stateParams.someID; // This id is used to search for a content of a specific type

var doSomething = function(id) {
    someservice.getData(id).then(function(data) { // getData function makes a request to API to fetch data
    vm.dataArea = data; // assigns data to the view
  });
};
  doSomething(vm.id); // First gets called to render the view

  // Methods create, delete, update not shown here, but they all broadcast the message updateMade upon being called

  $scope.$on(“updateMade”, function() {
    doSomething(vm.id);
  });


});

为什么IE / Edge不接收广播?这在任何其他浏览器中似乎都不是问题。

0 个答案:

没有答案