search

Home  >  Q&A  >  body text

angular.js - What is the specific meaning of $emit(,)?

This request interface has this code after the $scope.$apply() syntax of success. What does it mean specifically?

PHP中文网PHP中文网2783 days ago837

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-15 17:13:07

    The function is to tell its parent $scope that an event has been triggered. The name of the event is boyslist, and the data is result.data

    If your parent $scope is listening for this event, the callback function inside will be triggered, for example

    $scope.$on('boyslist', console.log);

    This will print it out

    Scope Events Propagation
    Scopes can propagate events in similar fashion to DOM events. The event can be broadcasted to the scope children or emitted to scope parents.

    You can read this for details, and then look at Scope Events Propagationthat little piece

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 17:13:07

    Transfer child controller data to parent controller

    reply
    0
  • Cancelreply